views:

21

answers:

3

I am using a 3rd party control that exposes a bunch of dependency properties (ex: SomeNumber) but do not supply corresponding changed events (ex: SomeNumberChanged). I would like to handle the event when the value changes. I know there is the OnPropertyChanged callback when you register the DP, but is there a way to hook into this when you are not the one registering it?

A: 

Instead of trying to hook into the third party metadata, just make your own Dependency Property and data bind to the third party property.

This way, you'll get the notification on your property, whenever either one is changed.

Reed Copsey
So this would involve creating a derived class for each 3rd party object? seems like a lot of work ...
TheSean
@TheSean: Not necessarily - it depends on what you're trying to do. You can always make a single (generic) class that can do this for any DP, if you wanted... However, typically, when using a 3rd party component, you're putting this into your own code, and trying to do your own changes. Just put the property (with changes) there. You can alternatively implement INPC on your class and bind to a 3rd party DP, and just have it in the setter...
Reed Copsey
A: 

You are aware that you can register a callback with them with the DependencyProperty mechanism itself? ;)

TomTom
This is done at creation time - if that's out of the OP's control, it's not as straightforward as you're suggesting... (Plus, overriding the DP's metadata might have adverse effects on the 3rd party control.)
Reed Copsey
A: 

The object having the dependency property SomeProperty has a static property SomePropertyProperty (or something like that). This property has its own Changed event.

CommanderZ