On further research, we found that the Prism framework is not quite ready for version 4 silverlight. The Prism team are currently revamping Prism to use MEF (Managed Extendability Framework) and while they have begun producing code drops (they are on Drop 3), these are still in alpha, so we can't use them yet.

So to bridge the gap while the Patterns team works towards full release, we decided to use the MVVM Light framework from Laurent Bugnion of Galasoft. It provides a simplified version of Prism's feature set, and has proven to be a great framework to work with.

MVVM light provides:

  • Commanding - RelayCommand object that can be used with Sivleright 4 button commands, and has an extension that bridges other controls that don't yet have commanding
  • Messaging - A great messenger framework for decoupling viewmodels from each other by sending messages instead of binding
  • Blend support - MVVM light has been built with Blend support in mind, and works very well with Blend. This gets around another deficiency in the current Prism implementation, which doesn't play well with Blend.
  • ViewModelBase - base class for viewmodels
  • Templates - for Blend and Visual studio. It also include some code snippets to help with code writing.

I would recommend using MVVM light if you are looking for a good, simple way of making MVVM easier and more clear to work with. It works extremely well with MEF - we have now refactored a complex Silverlight application to use MVVM light and MEF in less than a week.

Sean Wildermuth has a great 4 part example series on using MVVM light with MEF to build an MVVM based Silverlight application. The source included with the examples also has a fantastic error handling, status message and centralized IsBusy indicator setup that leverages the MVVM messaging framework.


We have been doing extensive development using Silverlight, and have run into some barriers with the design of the application we are working on. Some of the issues we were able to mitigate with MVVM pattern. However, as the app has become more complex, dependencies have crept in between the viewmodels and the parent application.We are also running into trouble managing commands and events associated with the application - how do you have several components subscribe to the same event set without having to connect viewmodels together?

The application's Xap file has also grown to be fairly large, and it will be necessary to split the application up into separate chunks that are loaded only when required. Our current structure will not allow this.

Upon doing research into how to address these issues, I discovered the Prism framework from the Microsoft Patterns and Practices group. This appeared to be a great way to address a number of the issues.

Prism is a framework for composing applications from separate modules. It contains an approach for injecting components into others using the Unity framework (also a patterns and practices framework) to eliminate dependencies. It also has a very nice looking commanding approach implemented through an event aggregator publish/subscribe mechanism.

However, during reading through commentary on Prism, I also found the Managed Extendability Framework, from a different part of Microsoft which looked initially like it was a competing approach to solve similar issues.

Microsoft often does things like this (take the whole Linq/ Linq-SQL/Ado.net entity framework/Windows Communication foundation maze as an example...) in which they come out with several almost the same but not completely technology bits that overlap. Inevitably one of the approaches will be adopted at the expense of the other, which forces developers who adopted the wrong one to refactor to the winner.

 (More)