forcing a WPF binding to ‘refresh’ …


From an internal DL … I thought this would be handy — must admit is nicer than some hacks I have done in the past to accomplish same thing..


—  


Sent: Tuesday, July 03, 2007 2:00 PM
Subject: RE: forcing a rebuild of an items control…


 


You’ll need to know the dependency object and dependency property where the binding was defined, which may not qualify as elegant.  Then you can use this line:


 


BindingOperations.GetBindingExpressionBase(dependencyObject, dependencyProperty).UpdateTarget();


 


–Eric


 


Sent: Tuesday, July 03, 2007 1:08 PM
Subject: forcing a rebuild of an items control…


 


I have a control that has a list of stuff, and once I make a change to some unrelated thing I really need to force the binding to re-run… is there any elegant way to make this happen? Something like “InvalidateMeasure” but for binding… ?


 

Comments (2)

  1. FKruesch says:

    That’s pretty much the same thing that you’d do when you set the updatesourcetrigger to explicit in a binding, right?

    like: myTextBox.GetBindingExpression(TextBox.TextProperty).UpdateTarget();

    cheers

    Florian