How to attach a ChangeEvent handler to an inherited dependency property?
-
08-06-2019 - |
Question
How would you attach a propertychanged callback to a property that is inherited? Like such:
class A {
DependencyProperty prop;
}
class B : A {
//...
prop.AddListener(PropertyChangeCallback);
}
Solution
(edited to remove recommendation to use DependencyPropertyDescriptor, which is not available in Silverlight)
OTHER TIPS
Have you tried a two way data binding between the two dependency properties?
@MojoFilter,
Jon's last suggestion link will give you what you're looking for: it uses weak references to register listening to changes by wrapping properties in a new object. Scroll to the bottom of "PropertyDescriptor AddValueChanged Alternative". You'll have to change the Binding code around a bit since BindingOperations doesn't exist.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow