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

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.

Installation

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!

Cheers,
Laurent

 

Print | posted on Monday, October 03, 2011 9:28 PM

Feedback

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

left by A V at 10/4/2011 8:43 AM Gravatar
Thanks. Is there a concept of modules in Windows 8 like in Silverlight? If yes, will MVVM Toolkit handle modules and loading them in the future? Love your toolkit extras.

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

left by Stimul8d at 10/4/2011 10:58 AM Gravatar
Hot Damn, Laurent. Your'e FAST!

It's really nice to see how much commitment you have to this project. Kudos to you.

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

left by Paulo Quicoli at 10/4/2011 12:51 PM Gravatar
Hi Laurent. About your felling of MessageBoxResult I have a suggestion. Mark (from Julmar) has made a good abstraction in "ShowMessage" features. In his MVVM framework (MVVM Helpers)this kind of feature is contained in "Services", which exposes an Interface. This Interface exposes its own MessageResult, not depending on OS values. So, we can implement that Interface independently and register it for ShowMessage service (using a simple IoC container).

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

left by Bruce Abernethy at 10/6/2011 2:06 PM Gravatar
Thanks for getting this out so quickly - will try it out and give feedback soon. Will miss EventToCommand though - I probably over use that, but man does it come in handy all over the place (why something like this isn't "stock" yet is beyond me).

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

left by ATIF at 3/6/2012 6:19 PM Gravatar
Hi iam trying to use in Windows 8 consumer preview in Visual studio 11 but when i select templete and create new project i get an error.

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

left by Laurent at 3/6/2012 7:58 PM Gravatar
Hi,

The consumer preview has a few breaking changes, I am working on an update. Stay tuned to my blog for an announcement.

Cheers
Laurent

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

left by Daniel at 4/10/2012 4:09 PM Gravatar
Is this the release you were working on MVVM Light V4b1 for Windows 8 Consumer Preview ?

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

left by Laurent at 4/12/2012 8:41 AM Gravatar
Hi,

This one was for the developer preview of Windows 8 (all these previews are very confusing...). For the newest version that will work on the Consumer Preview, check this: http://blog.galasoft.ch/archive/2012/04/01/mvvm-light-v4b1-for-windows-8-consumer-preview-with-installer.aspx

Cheers,
Laurent

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

left by jorge at 4/13/2012 7:33 PM Gravatar
will your next release have EventToCommand? Is this high priority? Thanks for your work.... miss eventtocommand!!!

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

left by Laurent Bugnion at 4/13/2012 8:12 PM Gravatar
Hi,

This is unfortunately out of my control. Microsoft didn't port behaviors to Windows 8 yet, and EventToCommand is a behavior.

What you can do is take your request to the Blend team and let them know how important behaviors are (I already did that at my level).

For instance, you could leave a comment here:
http://blendinsider.com/technical/xaml-authoring-in-blend-and-vs-workflow-tools-and-tasks-2012-04-02/

Alternatively, send me an email with your argumentary and I will forward.

Cheers,
Laurent

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

left by Melvin at 4/19/2012 8:57 AM Gravatar
Hello, is it safe to start using MVVM Light for an app that I plan to put on the market later on? If not, is there an ETA of when will it be? Btw, great work! I've been watching all of your videos and I love the quality of your products. Thanks!

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

left by Melvin at 4/19/2012 9:05 AM Gravatar
And one more question. I've been searching around the web on how to comply with the MIT license, but there's a lot of confusion and different opinions. What exactly do I have to do to be able to redistribute this library under compliance with the MIT license?

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

left by Laurent at 4/19/2012 10:54 AM Gravatar
Hi,

MVVM Light V4 is in RC state, meaning that I don't foresee any major change. I plan to RTM it in a few days anyway. So yes I would say that it is safe to work with it. Note that there is no installer right now for the RC, I am working on that. I expect I will have an installer ready this weekend. I would recommend that you wait until then. I will post on my blog when the installer for V4RC is available.

Regarding the license, for MIT, what is requested is merely attribution. So it is enough if you have a place in or around your product that mentions that you are using MVVM Light, and links to http://www.galasoft.ch/mvvm. That said I am not fixated on that, and you have my assurance that I won't sue you if you don't do it ;)

Cheers,
Laurent

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

left by Martino Bordin at 4/28/2012 1:46 AM Gravatar
Hi Laurent, is it available a sample application using MVVMLight with Metro?

Thanks and keep pushing your framework...it's awesome!

Martino

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

left by Laurent at 4/28/2012 11:06 AM Gravatar
Hi,

If you go to http://blog.galasoft.ch/archive/2012/04/18/slides-and-source-code-for-my-past-talks-this-year.aspx you will find two videos. The MVVM Applied one shows an example of an MVVM Light application on Windows 8. Source code is also available in the same blog article.

Cheers,
Laurent

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

left by sayhello at 5/21/2012 8:34 AM Gravatar
Hi! Laurent,could you introduce how to use navigateservice in viewmodel. It is the first touch metroapp with mvvm for me .
Here is my code it works well in my first phone7 app,but in metro app it threw an exception.

interface INavigationService
{
void GoBack();
void GoBack(string parameter);
void NavigateTo<S>(Type pageName, S param) ;
event NavigatingCancelEventHandler Navigating;

bool HasQueryString { get; }


}

thanks.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: