MVVM Light Toolkit for Windows 8 (preview) #mvvmlight #win8

.NET, Build, MVVM, Technical stuff, Windows 8, Work
No Comments

This post was imported from my old blog and had 21 comments which are included as a screenshot at the end of this post.

I was very optimistic when I first saw Metro style apps coded in C# on Windows 8, because for the most part they are not much different than the well known XAML/C# pair on Silverlight or WPF. This led me to brag a bit about probably having a port of MVVM Light ready “in a few days”. Of course I didn’t take in account that I would have a great time the week after //build in Seattle, with fantastic weather and tons of friends to have dinner and conversations with. Needless to say, the few days turned out, in fact, to be a couple of weeks.

Nonetheless, I am proud and happy to announce the availability of MVVM Light Toolkit for Windows 8. Let’s be clear, this is a preview version. All the unit tests are green for the selected components (there are a couple of components not ported yet, see the section below titled “Missing components”). However, a green unit test does not quite mean that the tested component is completely safe to use, so please be careful with that material and send me your feedback if you find issues.


MVVM Light for Windows 8 is a side-by-side install with the standard MVVM Light V3 or V4 beta. Simply download and run the MSI from Codeplex. As usual, the last step of the installation performs a “/setup” of Visual Studio to actualize the project template cache, and unfortunately this last step can last very long. Please be patient and don’t cancel before the end! The installation process is very similar to that described on the MVVM Light installation page (except that there is no NuGet installer for VS11 yet).

Note however that if you uninstall MVVM Light V3/V4b, but still want to keep MVVM Light for Win8, you may have to repair MVVM Light for Win8. Simply run the installer again and select “Repair”.

Ported components

Almost all MVVM Light components are also available in the Windows 8 version. The ported components are:

  • ObservableObject including all ways to raise PropertyChanged.
  • ViewModelBase including all ways to raise PropertyChanged.
  • Messenger including all message types except DialogMessage (see below).
  • RelayCommand with and without parameter.
  • SimpleIoc which might well be the very first IOC container working on Windows 8.

File, New Project

I also created a Metro style version of the MVVM Light project template. To create a new MVVM Light-powered Metro Style application, follow the steps:

  • Select the menu File, New, Project.
  • In the New Project dialog, select the category Visual C# / Wndows Metro style and double click the MvvmLight (Win8) template.

The created application is a very simple MVVM application, very similar to the ones that get created in Silverlight, WPF or Windows Phone 7: it contains a model with IDataService, a dummy runtime implementation and a design time implementation. The ViewModelLocator is available and “wired” (using the SimpleIoc container) as well as a MainViewModel that is set as DataContext on the MainPage.

Missing components

  • Skins: There is a small change in the way that resource dictionaries are handled in Windows 8. I need to sort things out, so right now there is no “MainSkin.xaml” in the project template.
  • DialogMessage: This type is bugging me in V3/V4b because it is bringing the MessageBoxResult type into the ViewModel. I am looking at ways to make it better by converting the MessageBoxResult into a vanilla Boolean. In Windows 8, MessageBoxResult does not exist anymore (there is no MessageBox or popups of any kinds in Metro style apps). Consequently, the DialogMessage does not build, and I decided to just remove it for now. I will add it again when I refactor to the “vanilla” version.
  • EventToCommand: There are no Blend behaviors in Windows 8 yet (important word: yet). I am looking at ways to have behaviors on Windows 8 before Blend 5 for XAML gets released. Stay tuned.
  • DispatcherHelper: The Dispatcher object has changed quite a lot in Windows 8, and I am looking at ways to keep the DispatcherHelper compatible with previous versions of MVVM Light by wrapping these differences. It shouldn’t be a big deal, but I want to give myself a little time to get it right (hopefully).

Next steps

I intend to build a small sample application (very similar to the one I built for my MIX11 talk) to try the various components in real life conditions. This will of course be the topic of an upcoming blog post.

I encourage everyone to try these components in Windows 8 preview, and please don’t be shy with your feedback!


GalaSoft Laurent Bugnion
Laurent Bugnion (GalaSoft)
Share on Facebook

This post was imported from my old blog. Original comments screenshot: 12-3-2013 4-43-35 PM

Leave a Reply