Wpf binding not updating
OK, so the title is a little ambitious, but there is nothing wrong with setting yourself lofty aims!Because of the depth of this topic I have decided to split this tutorial up into a series of blog posts, each of which explore a different aspect of the binding framework.I don't usually write tutorial blog posts and series, preferring instead to develop new controls or novel techniques.However, I really felt this subject needed an in-depth tutorial.Databinding is a fundamental part of the WPF, Silverlight and the Silverlight for Windows Phone 7 frameworks.It is a powerful concept that once mastered allows you to write concise and elegant code.
We will also see how we can respond to event raised by these controls in order to update our model.
Note, that I am making the assumption that your code will contain some sort of model object. You could store your data within the UI controls directly, however this rapidly becomes un-maintainable.
There are a whole host of UI patterns that have been developed in order to keep the model and the view separate (MVP, MVC, MVVM etc...) We'll look at how to manage the interactions between the model and the view without the help of a binding framework.
For our example we'll look at a very simple UI which displays the details of an event, its name and the date of the event: The model that supports this view is shown below: , allowing us to detect changes in its properties.
We will use this to update the view when the model changes.
The view has the following XAML (with the various layout properties omitted for clarity): If we consider the model object to be the source of the data and the UI control to be the target.