Wpf contentcontrol binding not updating
Wpf contentcontrol binding not updating - dating older men site
That may lead to a counterintuitive situation when you want to specify some UI element content and then use bindings in that content.Let's take an example: I realize this is not what most of you have in mind when using a Content Control.
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.I'm building a graphical designer, based upon an article by Sukram in Code Project.I'm now trying to extend it so that each item on the canvas binds to a different View Model object - i.e. Every item on the designer is actually a Content Control, into which is placed a different template (based upon which toolbox item was dragged onto the canvas).Binding Expression: Path=Content Two Template Selector; Data Item='String' (Hash Code=-1506748533); target element is 'Content Presenter' (Name=''); target property is 'Content Template Selector' (type 'Data Template Selector') System. Data Error: 40 : Binding Expression path error: 'Content One Template' property not found on 'object' ''String' (Hash Code=-694847)'.Binding Expression: Path=Content One Template; Data Item='String' (Hash Code=-694847); target element is 'Content Presenter' (Name=''); target property is 'Content Template' (type 'Data Template') System. Data Error: 40 : Binding Expression path error: 'Content One Template Selector' property not found on 'object' ''String' (Hash Code=-694847)'.For example if in User List View, I click Add New User button, am taken to User Detail View, add details for a new User, click save, then navigate back to User List View - the newly created user is not in the view.
Note that I have debugged, and can confirm that the View Model has the correct data.If you declare a binding on the Content Presenter, the moment its content is set, the binding would be re-evaluated.For example, let’s say you are building a dual-content control like this: You would expect something like this,image below, right?The problem is that the view does not reflect the state of the View Model.It is like the app has cached the View from when it was first instantiated.Here is the process I followed to create this dialog.