views:

964

answers:

4

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);
}
+3  A: 

(edited to remove recommendation to use DependencyPropertyDescriptor, which is not available in Silverlight)

PropertyDescriptor AddValueChanged Alternative

Jon Galloway
None of the proposed solutions can be used at least directly with Silverlight.
Martin Liversage
Removed options that don't work in Silverilght. This one should, as verified by @Dimebrain
Jon Galloway
A: 

@Jon That was the first solution I found, unfortunately it looks like there is no DependencyPropertyDescriptor in Silverlight.

MojoFilter
A: 

Have you tried a two way data binding between the two dependency properties?

Brian Leahy
A: 

@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.

Daniel Crenna