Muzib
Muzib

Reputation: 2581

How to remove a Binding without clearing the current value?

Say I have a TextBlock namedtextBlock1 whose TextProperty is bound with another TextBox

To unbind the TextProperty, I have to do this:

textBlock1.ClearValue(TextBlock.TextProperty);

But doing that, I also erase the current text, which I don't want. I just want the TextBlock's text to stop changing when the property-it's-bound-to changes.

Upvotes: 2

Views: 285

Answers (1)

Romasz
Romasz

Reputation: 29792

It should work if you just set its value like this:

textBlock1.Text = textBlock1.Text;

Setting the string should destroy the binding.

Upvotes: 1

Related Questions