If you're a WPF developer and you're involved on developing enterprise level applications, I think that at least once a time you've thinked on what could be the best architecture for your application. Design Patterns are always the starting point to have in mind when architecturing a complex sofwtare system. But what's the best to choice?
I remember that, when writing Windows Form applications, my model of reference was the Model-View-Controller Design Pattern (MVC). But what about WPF?
The debats are always opened on this topic, but seems that the community of WPF developers agree on saying that the Design Patterns that fits well with WPF is what is called the Model-View-ViewModel Design Pattern:
In summary:
- The View has the associated ViewModel set as its DataContext so that the View can easily data bind to ViewModel properties
- The ViewModel reflects its changes to the Model by calling appropriate methods on the Model
- The ViewModel exposes ICommand that the View data bind to, in order to execute actions
- The Model signals its changes to the ViewModel by raising events
What I want to signal here is that on MSDN Magazine this month is appeared an interesting article about the MVVM Pattern written by Josh Smith. I highly recommend to read this article if you're a WPF developer. In my opinion this is one of the coolest real world sample on how to apply the Model-View-ViewModel pattern in order to architect a complex WPF application.
The time you'll spend on understanding the provided sample is gold... thanks Josh.