ReSharper for Windows Phone

Skip to end of metadata
Go to start of metadata

Just like development for the Silverlight and WPF platforms, development for Windows Phone involves interacting with two types of file – the XAML files that define the user interface, and the C# (.cs) files that serve as code-behind and define the logic of what happens in the application. ReSharper not only simplifies the editing of these files in isolation, but also provides functionality for changing both the XAML and code-behind in tandem.

Basic XML-Specific Features

The first thing that’s worth pointing out is that, since ReSharper supports XML, the XML-related features are correspondingly available in XAML, too. Thus, with the caret over an element, you will be presented with the following context actions:

Let’s briefly talk about what these do:

  • Replace tag lets you change the type of the tag with a different element – for example, changing Grid to my:SpecialGrid.
  • Replace all tags does the same as the above, with the exception that all inner definitions of Grid will also be changed. This means that if you have a Grid within a Grid, you end up with a my:SpecialGrid within a my:SpecialGrid.
  • Remove tag and promote children removes the tag itself, but all its contents get unindented and brought to the removed tag’s level.
  • Remove all tags and promote children does the same thing as the previous context action, but affects all elements of a specific type. This means that if you have several {{Grid}}s at the same scope, each one of these will be removed and its children promoted.

ReSharper knows how to expand and collapse empty elements. A closed element with no children offers the option to expand:

Whereas an expanded empty tag can be collapsed:

It’s also possible to promote an attribute to nested element:

The generated element correctly has the containing element’s prefix, so this

becomes this:

The inverse operation is, of course, also available:

In addition to the above context action, ReSharper also lets you reposition XML elements and attributes. By holding Ctrl+Alt+Shift, you can press the left and right arrow keys to move attributes within an element; holding the same combination and pressing the up and down keys moves the whole element you’re in (including its attributes and child elements) up and down within the containing element.

File Structure

Just like with ordinary code files, ReSharper’s File Structure window (Ctrl+Alt+F) is able to display the structure of the XAML file. You can also get this window to navigate to the element you select in the tree.


Resources are a core concept in WPF/Silverlight development, and ReSharper can help you create resources right in the XAML. For example, if you create a resource dictionary with a (still) nonexistent resource, ReSharper will offer you the option to produce a class for this resource:

There are two options here:

  • Create type creates a simple CLR type
  • Create WPF type creates a custom WPF control

Whichever option you choose, the namespace prefix will be correctly registered in the top-level element.

In addition to creation of resources, ReSharper also offers options for their destruction – for example, in cases where a resource is not used:

Speaking of resources, it’s possible to create one at any location within code: simply fire up Smart Completion (Ctrl+Alt+Space) in an empty element tag:

Choose whether you want a static or dynamic resource:

Give the resource a name, and ReSharper will offer you several options for actually creating the resource:

Picking one of these options will auto-generate a code stub for the corresponding type of resource. For example, for a Background property, ReSharper will offer the following options:

In-Place Refactoring & Navigation

Just like with ordinary code, ReSharper’s in-place refactoring capabilities (Ctrl+Shift+R) are available in XAML. For example, if you use a property in a data binding expression, you can access the same refactoring options as you would if you were on the property definition in a .cs file:

It’s also worth noting that some refactoring features are available for XAML-specific elements. For example, you can perform a Rename refactoring on a static resource key:

In the same vein, you can use the Navigate To (Alt+Backquote) menu for navigation from a particular symbol:

It’s also worth noting that both the refactoring and the navigation menus are also available in the File Structure and Solution Explorer windows.

Live Templates

ReSharper comes with the following XML-specific live templates:

  • The tc template creates a closed tag like <ThisOne />
  • The t template creates an open tag like <ThisOne></ThisOne>
  • The a template creates an attribute like thisOne=""

Of course, nothing prevents you from defining your own XML-specific templates. You can even constrain them to XAML files only by specifying the *.xaml file extension in the template’s availability window:

  • No labels