INotifyPropertyChanged is Obsolete
Please check you mailbox for the latest issue of CoDe Magazine. In it, you will find my article "INotifyPropertyChanged is Obsolete." A few things have changed since I penned those words, and now INotifyPropertyChanged is more obsolete than ever.
The article describes how to use Update Controls to replace WPF data binding. Rather than using the built-in "{Binding}" XAML extension, it tells you to use my "{u:Update}" custom extension. While this custom markup extension is still supported, it is no longer the preferred way to use Update Controls.
Blend-friendly updating
Thanks to some feedback from Paul Stovell, Microsoft MVP for Client Application Development, Update Controls now works with the "{Binding}" XAML extension. This makes it more Blend friendly. But before you give your object to the DataContext, you need to wrap it:
public partial class Window1 : Window { public Window1() { InitializeComponent(); DataContext = ForView.Wrap(new PersonViewModel(new Person())); } }
The wrapper implements INotifyPropertyChanged for you. It infers dependencies from your code and figures out when to fire PropertyChanged events. To help it with that inference, you need to mark your independent properties.
public class Person { private string _firstName; private string _lastName; #region Independent properties // Generated by Update Controls -------------------------------- private Independent _indFirstName = new Independent(); private Independent _indLastName = new Independent(); public string FirstName { get { _indFirstName.OnGet(); return _firstName; } set { _indFirstName.OnSet(); _firstName = value; } } public string LastName { get { _indLastName.OnGet(); return _lastName; } set { _indLastName.OnSet(); _lastName = value; } } // End generated code -------------------------------- #endregion public string FullName { get { return FirstName + " " + LastName; } } }
The Ctrl+D, G shortcut still works. Select the fields and hit the shortcut to generate the independent properties.
Update Controls can see right through the intermediate view model. There is no bookkeeping code required. Even the dependency of Title upon FirstName and LastName is inferred.
public class PersonViewModel { private Person _person; public PersonViewModel(Person person) { _person = person; } public string FirstName { get { return _person.FirstName; } set { _person.FirstName = value; } } public string LastName { get { return _person.LastName; } set { _person.LastName = value; } } public string FullName { get { return _person.FullName; } } public string Title { get { return "Person - " + FullName; } } }
Silverlight 3
I have also ported Update Controls to Silverlight. It only works with Silverlight 3, so it is in Beta until the official release. However, it is fully operational and works just as well as the WPF version. The "{u:Update}" custom extension is not supported in Silverlight, however. You have to use the new ForView.Wrap() mechanism.
I hope you find Update Controls to be as useful as I have. You can download the source code provided in the article from CoDe Magazine, or try some demos that I've created since then:
- Commuter - Multi-threaded iTunes synchronization sample.
- QuickWriter - Data binding through linq queries. Uses the {u:Update} extension rather than the new ForView.Wrap().
- UpdateControls.XAML.Test - The test app bundled with the source code.
- Addendum Demo - The code included above.
Also be sure to watch the videos to see it in action.

Recent comments
27 weeks 6 days ago