Category: ReSharper

Using ReSharper with Silverlight

I have found the article to show how to make use of ReSharper with Silverlight Apps.

Click here to check out the original post.

I have always known that the ReSharper is a great tool for developer productivity. But I have not got a chance to use it yet. If you haven’t already tried ReSharper, you can download it here.

Here is the main details of how to use ReSharper for Silverlight:

ReSharper has a great feature called Templates.  Templates give you the ability to quickly generate code that you would generally need to write by hand.  There are three different types of templates in ReSharper:

  • Live Templates – Allow you to generate code within the context of an existing file.
  • Surround Templates – Allow you to “surround” selected code with a pre-defined template.
  • File Templates – Allow you to quickly generate an entire file from a pre-defined template.

There are 4 templates that you can use in your Silverlight endeavors.  Below you will find a short description of each:

Dependency Property Generation

As illustrated in the screen capture below, you simply type DependProp in the editor, supply a property name and type, then hit tab and you have a fully defined dependency property!

 DependencyPropertyTemplate

Visual State Manager Block Template
The Visual State Manager Block Template is similar in function to the Dependency Property template, but this template will build a VisualStateManager declaration within the context of an XAML file.  To use the template, simply type vsm while editing an XML/XAML file.  The usage for this template is very similar to the DependProp template.

Generic.xaml File Template
As a Silverlight control developer, you may find it annoying to have to define the generic.xaml file over and over again.  Using a File Template, we can quickly build standard declaration and ReSharper will help you fill out the rest. To generate a new Generic.xaml file, press ALT+R+N+G, enter a name for the template and then click OK.

image 

image

Control File Template
The Control File Template will construct a basic class that inherits from Control and includes the DefaultStyleKey in the constructor. The usage for this template is the same as the Generic.xaml file template above.

Installing the Templates
To import these templates, select the File Templates tab in the ReSharper Templates Explorer.  Click the import button and select the SilverlightFileTemplates.xml file,then click ok. 

image

Importing the Live Templates is very similar.  Select the Live Templates tab in the ReSharper Templates Explorer.  Click the import button select the SilverlightLiveTemplates.xml file, then click Ok.

You can download the templates here:
Download Resharper Templates