djcouchycouch
djcouchycouch

Reputation: 12832

Programatically turn on and off databinding?

I have a text box declared in xaml that uses databinding to a string property. How do I disable and then re-enable binding in code?

Thanks!

Upvotes: 1

Views: 291

Answers (2)

Reed Copsey
Reed Copsey

Reputation: 564861

You can use BindingOperations.ClearBinding to remove a binding, and BindingOperations.SetBinding to add it back in.

Upvotes: 3

Andy
Andy

Reputation: 30418

I'm not sure if it would work or not, but you could try calling FrameworkElement.SetBinding(), and pass null for the second parameter.

Upvotes: 0

Related Questions