1

I am looking at this,

Clear Binding in Silverlight (Remove Data Binding from SetBinding)

But to clear bindings you have to specify a dependency property.

Is there a way to generically find all the bindings on a DependencyObject and clear them?

Thanks.

Community
  • 1
  • 1
peter
  • 13,009
  • 22
  • 82
  • 142
  • A big problem you have is that the answer in the question you link is not actually removing a binding. There is no API to remove a binding. – AnthonyWJones Dec 10 '10 at 13:18
  • Sorry Anthony, the comment you are making there doesn't make sense to me. – peter Dec 13 '10 at 02:05

1 Answers1

1

How about iterating over all the static dependency properties (using Reflection) of that control's type and resetting bindings on them?

decyclone
  • 30,394
  • 6
  • 63
  • 80
  • That would be part of the solution but the trickiest bit is actually removing the binding. – AnthonyWJones Dec 10 '10 at 13:17
  • You already have a `DependenctObject`, you get it's type, list all of its `DependencyProperties` and you call the method in your reference link with these values. That should do it. – decyclone Dec 10 '10 at 13:19
  • Reflection, isn't that quite slow? Could that become a performance issue if iterating over a complete visual tree and doing that to every item? – peter Dec 12 '10 at 21:17
  • Anyway just thinking out loud. I will give it a go and let you know! – peter Dec 12 '10 at 21:19