Fixing the #mvvmlight code snippets in Visual Studio 11

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

 

Print | posted on Friday, April 06, 2012 12:07 PM

Feedback

# re: Fixing the #mvvmlight code snippets in Visual Studio 11

left by vietnam online at 4/13/2012 10:40 AM Gravatar
Really helpful post. Thank you very much. I've done to fix my problem!

# re: Fixing the #mvvmlight code snippets in Visual Studio 11

left by Victor at 4/19/2012 3:36 AM Gravatar
Brilliant, thank you! I installed the toolkit in VS2010 for a WP7 app and didn't have the snippets.

# re: Fixing the #mvvmlight code snippets in Visual Studio 11

left by Laurent at 4/19/2012 10:51 AM Gravatar
For info, this is fixed in the next release (V4 RC, the installer will come out in the next few days).

Cheers,
Laurent

# re: Fixing the #mvvmlight code snippets in Visual Studio 11

left by Karl at 11/5/2012 8:02 AM Gravatar
Hi Laurent, I've installed latest version of MVVMlight for VS2012. But the code snippets aren't there. So I applied this fix manually - now snippets are shown in the Code Snippets Manager. Unfortunately I still cannot type them out using shortcuts. What else can be done? (Im using Win7, with Resharper 7.0 installed)

# re: Fixing the #mvvmlight code snippets in Visual Studio 11

left by Karl at 11/5/2012 8:53 AM Gravatar
For some reason, after a restart it works now. Thank you for all the great stuff!

# re: Fixing the #mvvmlight code snippets in Visual Studio 11

left by Jamey at 1/17/2013 8:31 PM Gravatar
I am using VS2010 and just uninstalled mvvmlight 4.0.23.1 and ran the CleanOldFiles.exe. I used the NuGet command to install the latest version on my project and now I have no code snippets or directory to point to as directed in this article. What now?
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: