← About Jeff

Helpful Silverlight Snippets

February 10, 2010

Here are a few of the Visual Studio C# code snippets that we use on the Silverlight team when building controls and apps.

Download a zip (7 KB) of them all and extract them into your Snippets folder, which is in your Documents folder: Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets\. These also work with Visual Studio 2008.

To use a snippet

Inside the code editor, start typing the name of the snippet (such as dp, for a standard dependency property declaration section with a change handler). You should see it in the Intellisense drop-down.

ISDropdown 

Press tab to accept the value.

If there are editing helpers for the snippet, use tab to move through the fields as you fill them out.

ISCompletion

Press Enter when you are finished. This should drop you right into the triple-slash comment field to fill that out.

Included snippets

Name Description
dp A standard dependency property with a property changed handler
dp_attached An attached property declaration
dp_nohandler A dependency property without a change handler
dp_value A value type dependency property with change handler
dp_value_nohandler A value type dependency property without a change handler
inot An INotifyPropertyChanged implementation
test A simple unit test method, descriptive comment, and description attribute
testa An asynchronous unit test method

Hope this helps.