Project Description
Provides support for adding XAML code snippets in the Visual Studio 2010 code editor for XAML in WPF and Silverlight projects.

The addin has been written in Visual Basic 2010 and actually targets Visual Studio 2010 RTM. It uses and creates classic .Snippet files for XML syntax. At runtime the XML markup is simply pasted as XAML in the code editor. You use it as follows:

1. to insert a code snippet, right click the code editor and select Insert XAML Code Snippet from the context menu:

XamlSnippets1.jpg

2. in the appearing dialog select the folder containing your XML .Snippet files and then select the desired snippet:

XamlSnippets2.jpg

Notice that if you pass the mouse over the Code cell, a tooltip will show the full markup:

XamlSnippets3.jpg

3. Click Insert Snippet, and your code snippet will be added to your XAML code:

XamlSnippets4.jpg

4. To export some code to a .Snippet file for XML, simply select the code and right click. Then choose the Export selection as XAML Snippet command from the context menu. In the appearing dialog specify the snippet properties and click Export:

XamlSnippets5.jpg

LIMITATIONS AND FUTURE IMPROVEMENTS
There are some limitations: for example, the addin creates dialogs for inserting and exporting snippets. This is because the XAML code editor doesn't actually support code snippets like in VB or C# editors; then, in order to browse for snippets subfolder you need to click the "..." button each time you want to move to a different folder; another limitation is that you need to manually organize snippets in subfolders. Also, there is no support for the Code Snippet Manager tool (and the reason is still that the XAML editor has no native snippets support).

Developed by Alessandro Del Sole, Microsoft MVP

FEEDBACK
Please provide your feedback. I'm very interested in understanding if you like using the classic .Snippet file format by storing XAML code in the form of XML.

Last edited Nov 13, 2011 at 3:08 PM by AlessandroDelSole, version 8