Archive for the ‘WPF’ tag
Update Views through events between their ViewModels
Lately I’ve been developing standalone WPF applications using Visual Basic. To make a WPF application somewhat easy to maintain and extend it is extremely important to use some design pattern. The most popular design pattern around when developing WPF applications is the MVVM pattern (Model-View-ViewModel).
Developing a single view application is really really straight forward using the MVVM pattern, but when it comes to multiple views application there is no simple solution to update one or more views from another view and still make the Views and ViewModels behind them loosely coupled. When I say update I mean making some property change in the ViewModels behind the Views to be affected by the change of something in another View or ViewModel.
In this post I will show how I’ve solved the problem using events and delegates. Before I describe my solution, please read about the basics in the MVVM design pattern. There are a lot of good publications around, e.g. THE MODEL-VIEW-VIEWMODEL (MVVM) DESIGN PATTERN FOR WPF and Model View ViewModel (Wikipedia).
To make it easier to understand this post and to make it easier for me to write it, please read the following article if you’re not familiar with WPF data binding and the usage of INotifyPropertyChanged: http://coredotnet.blogspot.com/2006/05/wpf-data-binding-tutorial.html.