Fixing the #mvvmlight code snippets in Visual Studio 11

Posted by Laurent Bugnion on Geeks with Blogs See other posts from Geeks with Blogs or by Laurent Bugnion
Published on Fri, 06 Apr 2012 10:07:49 GMT Indexed on 2012/04/06 11:30 UTC
Read the original article Hit count: 406

Filed under:

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.

Cheers
Laurent

 

© Geeks with Blogs or respective owner