Fixing the #mvvmlight code snippets in Visual Studio 11

.NET, MVVM, Technical stuff, Windows 8, Work
See comments

If you installed the latest MVVM Light version for Windows 8, you may encounter an issue where code snippets are not displayed correctly in the Intellisense popup. I am working on a fix, but for now here is how you can solve the issue manually.

The code snippets

MVVM Light, when installed correctly, will install a set of code snippets that are very useful to allow you to type less code. As I use to say, code is where bugs are, so you want to type as little of that as possible ;) With code snippets, you can easily auto-insert segments of code and easily replace the keywords where needed. For instance, every coder who uses MVVM as his favorite UI pattern for XAML based development is used to the INotifyPropertyChanged implementation, and how boring it can be to type these “observable properties”. Obviously a good fix would be something like an “Observable” attribute, but that is not supported in the language or the framework for the moment. Another fix involves “IL weaving”, which is a post-build operation modifying the generate IL code and inserting the “RaisePropertyChanged” instruction. I admire the invention of those who developed that, but it feels a bit too much like magic to me. I prefer more “down to earth” solutions, and thus I use the code snippets.

Fixing the issue

Normally, you should see the code snippets in Intellisense when you position your cursor in a C# file and type mvvm. All MVVM Light snippets start with these 4 letters.

mvvm snippets in Intellisense
Normal MVVM Light code snippets

However, in Windows 8 CP, there is an issue that prevents them to appear correctly, so you won’t see them in the Intellisense windows. To restore that, follow the steps:

  • In Visual Studio 11, open the menu Tools, Code Snippets Manager.
  • In the combobox, select Visual C#. Code Snippets Manager
  • Press Add…
  • Navigate to C:\Program Files (x86)\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\SnippetsWin8 and select the CSharp folder.
  • Press Select Folder.
  • Press OK to close the Code Snippets Manager.

Now if you type mvvm in a C# file, you should see the snippets in your Intellisense window.


Previous entry | Next blog entry

Responses to “Fixing the #mvvmlight code snippets in Visual Studio 11”

  1. Serge Says:

    I used the NuGet to install the latest version of MVVMLight (Visual Studio 2010 – MVVM Light V4.4.32.1 has not installer for it). As it is expected there are no snippents have been installed. I downloaded snippents (CSharp)from codeplex and added it to Code Snippets Manager. It works.. even with resharper (Ctrl+J)

  2. lbugnion Says:

    I am working on an installer but as with everything some other stuff is getting in the way :) the “old” snippets should work just fine with V4.4.32.1

Comments for Fixing the #mvvmlight code snippets in Visual Studio 11