NOVA Code Camp: Separate Your Concerns with MVVM

I gave a talk today at the NOVA Code Camp on the MVVM pattern in WPF and Silverlight.

Some of the key highlights and takeaways are:

  • MVVM is based on the Presentation Model pattern
  • MVVM is all about separation of concerns and loose coupling
  • The ViewModel’s responsibility is to offer up state to the view in the way the view wants to see it
  • The ViewModel contains and manipulates state
  • View.DataContext = ViewModel is the relationship between view and ViewModel
  • The View data binds properties on elements to properties on the ViewModel
  • The View elements fire commands via data bindings on command properties on the ViewModel to manifest behavior in the ViewModel
  • Parent ViewModels can contain child ViewModels to allow the views to compose via DataTemplates
  • ViewModels can contain logic that manipulates the state including loading/updating state, validating state, computing values, and other kinds of logic that is not readily accessible in the model

A good source of info and examples on MVVM is the upcoming Prism 4 release, which already has public drops that include the MVVM QuickStart and a future drop will contain a more complicated MVVM Reference Implementation (bigger sample).

You can grab the slides and demos here:SlidesDemos