天天看點

MVVM Light Toolkit Patch for WP7 Mango Beta

in Programming /        MVVM Light Toolkit For more information about the toolkit in general, please refer to the Get Started page on my website.

On Tuesday the 24th of May 2011, the new version of the Windows Phone 7 SDK codenamed “Mango” was released to the public in beta. This is a huge iteration with an extremely large number of new APIs. Most exciting, the version of the Silverlight framework now used in Windows Phone 7 is Silverlight 4. Thanks to this, I was able to recompile the MVVM Light Toolkit for Windows Phone 7 based on the Silverlight 4 version. This is interesting because the Silverlight 3 version had a few hacks I had to build in to work around some limitations of the framework. Now in Silverlight 4, the code is leaner and cleaner.

Who should install the patch?

You should only install the patch if you work with the new version of the Windows Phone 7 tools (Windows Phone 7.1) released on Tuesday the 24th of May 2011.

The patch presupposes that you already installed the MVVM Light Toolkit as described here.

What is contained in the patch?

I created a patch for the binaries (new WP71 DLLs) and for the Project Template, which allows you to create a new MVVM Light application for Windows Phone 7.1 and immediately start with the new version of the framework.

On the other hand, the snippets and the item templates remain unchanged.

How to install?

In order to install the patch, follow the steps:

Installing the binaries

  • Download the binaries    
    • If you work with MVVM Light Toolkit V3 (official stable release), download the binaries here.
    • If you work with MVVM Light Toolkit V4 (preview version), download the binaries here.

Note: You can find the version with which you are working by right-clicking on one of the MVVM Light DLLs and selecting Properties from the context menu. Then, in the Properties dialog, go to Details and see the product version.

  • Unblock the downloaded Zip file.
MVVM Light Toolkit Patch for WP7 Mango Beta
  • On Windows 7: Right click on the file and choose Extract All.
  • Change the “Files will be extracted to this folder” field to “C:”
MVVM Light Toolkit Patch for WP7 Mango Beta
  • Confirm that you want to merge the files into the Program Files folder. You might have to provide permission for this operation.
MVVM Light Toolkit Patch for WP7 Mango Beta
  • In other operating systems, use your favorite method to extract the zipped binaries. The target folder should be:    

    C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries

Installing the project template in Visual Studio 2010 (not Express)

  • Download the Zip file from here.
  • Unblock the downloaded Zip file.
  • In Visual Studio, check the location from which templates are loaded:    

    Tools / Options / Projects and Solutions

MVVM Light Toolkit Patch for WP7 Mango Beta
  • Copy the path without the ProjectTemplates folder from “User project templates location”.    

    For example, in the example above, copy D:\Visual Studio 2010\Templates

  • Right click on the zip file and select Extract All.
  • Paste the copied path into the “Files will be extracted to this folder” field and then extract the content. Confirm that you want to merge the folders (and maybe overwrite files, if you had a previous version installed).
MVVM Light Toolkit Patch for WP7 Mango Beta

Installing the project template in Visual Studio 2010 Express (Phone Edition)

  • Download the Zip file from here.
  • Unblock the downloaded Zip file.
  • Right click on the zip file and select Extract All.
  • Select your "My Documents" folder as the target for the extraction. On Windows 7, it is c:\users\[username]\Documents.
  • Paste the copied path into the “Files will be extracted to this folder” field and then extract the content. Confirm that you want to merge the folders (and maybe overwrite files, if you had a previous version installed).
MVVM Light Toolkit Patch for WP7 Mango Beta

Upgrading an existing project

In case you are converting an existing Windows Phone 7 project to Windows Phone 7.1, you will need to change the reference to the DLLs. To upgrade your Windows Phone 7 application to Windows Phone 7.1, follow the steps:

  • Make sure that you have the Windows Phone 7.1 tools installed.
  • Open your application in Visual Studio.
  • In the Solution Explorer, right click on the project and select Properties from the context menu.
  • On the Application tab, change the Target Windows Phone Version combobox from Windows Phone 7 to Windows Phone 7.1
MVVM Light Toolkit Patch for WP7 Mango Beta
  • In the References folder, delete GalaSoft.MvvmLight, GalaSoft.MvvmLight.Extras and System.Windows.Interactivity.
MVVM Light Toolkit Patch for WP7 Mango Beta
  • Add the new references from the folder C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WP71.
MVVM Light Toolkit Patch for WP7 Mango Beta
  • In your XAML, look for possible references to GalaSoft.MvvmLight.WP7 or GalaSoft.MvvmLight.Extras.WP7 and replace with GalaSoft.MvvmLight.WP71, respectively GalaSoft.MvvmLight.Extras.WP71. Such a reference may exist if you have, for instance, used the EventToCommand behavior.

Note: in MVVM Light V4, there is also a new DLL named Microsoft.Practices.ServiceLocation.

Happy Mango coding!!

Laurent

繼續閱讀