J'ai 2 contrôles A et B qui ont besoin de partager une propriété de dépendance.DependencyProperty.Register() utilisation?
A a la propriété définie par:
readonly static DependencyProperty PathProperty = DependencyProperty.Register ("PathProperty", typeof (string), typeof (A), nouveau PropertyMetadata (string.Empty, OnPathChanged)) ;
public string Path
{
get { return (string)GetValue(PathProperty); }
private set { SetValue(PathProperty, value); }
}
private static void OnPathChanged(DependencyObject dobj, DependencyPropertyChangedEventArgs args)
{
//Dos something
}
A l'intérieur de la classe B, j'ai
readonly public static DependencyProperty Path = A.PathProperty.AddOwner (typeof (B));
public string Path
{
get { return (string)GetValue(Path); }
set { SetValue(Path, value); }
}
Maintenant, si je mets la propriété de dépendance sur le chemin B ... explictly (à partir du code comme Binstance.Path = « valeur ») Je me attends OnPathChangedmethod à feu à l'intérieur d'un contrôle?
N'est-ce pas le comportement attendu ou ai-je oublié quelque chose? Comment puis-je faire fonctionner ça? ... i.e changer la propriété du chemin sur B devrait déclencher OnPAthChanged sur A
Merci!