David Ward
David Ward

Reputation: 3829

WPF - Reevaluate OneWay Binding

I have a control whose binding is set as OneWay.

How can I force the value to be re-evaluated in code?

Upvotes: 2

Views: 1520

Answers (1)

Martin Harris
Martin Harris

Reputation: 28637

Get the binding expression and call UpdateTarget:

BindingExpression binding = Control.GetBindingExpression(TextBox.TextProperty)
binding.UpdateTarget()

Of course, if you implement the INotifyPropertyChanged interface on the class that holds the source property for your binding then WPF will handle the updating for you automatically.

Upvotes: 3

Related Questions