m0sa
m0sa

Reputation: 10940

Get all bindings to a DependencyProperty

I am wondering if it is possible to get all bindings that have a given DependencyProperty set as their source?

I was looking at the DependencyPropertyDescriptor class via the DependencyPropertyDescriptor.FromProperty(DependencyProperty, Type) method, unfortunately without success. It only allows to register a listener for change notification, but it has no way to inspect the registered listeners (being bindings in my case).

I also looked in the BindingOperation class, where all operations work only on binding targets, not sources.

It would even suffice if I could get my hands on the multicast delegate of the registered listeners and get the invocation list.

Edit

After using some reflector magic I decided to try hooking into the Add/Remove ValueChanged methods on the PropertyDescriptor by implementing the ICustomTypeDescriptor and intercepting the GetProperties method. From there i could intercept the delegates that are registering for change notifications...

Upvotes: 3

Views: 668

Answers (1)

Vinit Sankhe
Vinit Sankhe

Reputation: 19885

Well I would also be interested to know this! Probably microsoft never gave any such API because its a counter-dependency requirement. In WPF the GUI (the Target!) is the driver for dependency value changes so all dependency properties rise or attach with target gui hence the APIs are target driven than the sources (which could be many for that target!).

Upvotes: 1

Related Questions