Wpf usercontrol binding not updating
The good control shows correct language of the selected country.The bad control shows correct language when the menu is first invoked, and then keeps showing that language even if selected country changes.Update Controls is an open source library that replaces event-based data binding with automatic discovery and updating. WPF data binding requires that a bindable class implement the INotify Property Changed interface.This interface is fairly easy to implement as it requires only a single event: Property Changed.Context Menu Data (21K): Visual Studio 2010 solution I created a simple sample that illustrates the problem.It contains a list box with country names and two user controls: the "good" and the "bad". They also have right click menu to show country language.Most of the resources on the web specify that Content Presenter supports a special property called Content Source, with a default value of “Content“, which makes it easy for it to automatically set the values of these properties used to render content: Basically, the property specifies the string prefix used to bind to properties of the parent.If you change the value of the Content Source property to something else, like “Header“, the Content Presenter’s properties would auto-bind to bind to these properties of the control you are templating using Control Template: Why is it important? Bindings are resolved relatived to the value of the Data Context property.
Finally, there are things (this, this, this, this, this, and this) that simply perform worse than you likely expect.
By day, Michael is a solutions architect at Amerisource Bergen Specialty Group where he delivers high quality enterprise software in . By night, he writes mobile applications in Java for the Andriod platform.
He blogs his discoveries along the way at Adventures In Software (
This happens because the menu gets first created on right click and then acquires the (correct) data context from the parent.
On subsequent right clicks the same menu object is reused (as proved by the "Same menu?