coderushforroslyn-117437-getting-started-features-by-language-features-for-xaml.md
This topic contains information about the main CodeRush features for XAML.
Place the caret in a resource dictionary source or image source and press F12 to open the dictionary or image in XAML code.
CodeRush can navigate to an identifier declaration (in markup or code behind) from any reference in a XAML file: tag, markup extension, etc.
Place the caret in an identifier and press F12.
You can jump to a named element from any place in your XAML code.
Invoke the Jump To window with the Ctrl + Alt + N shortcut.
Choose XAML Element in the Jump To window.
Select the element from the “Available locations” list.
For more information on CodeRush navigation features, see Navigation and Search Tools.
You can use the built-in templates from the template library or write your own to facilitate code creation.
The following example shows how to expand the “ g3x2 “ template with the Tab key to create a grid with three columns and two rows:
CodeRush also includes a binding template library. The example below shows how to expand the “ben” template to bind a text block to the ComboBox SelectedItem.Content property.
For more information on templates, see Code Templates.
XAML markup has deep and complex structure that can be difficult to understand. CodeRush can format any XAML document to improve code readability and layout.
After execution, each tag’s indentation corresponds to its folding level.
This code formatter collapses the attributes of a XAML tag into a single line or breaks them apart.
For more information on code formatters, see Code Formatters.
You can extract an attribute from a XAML tag and make it a child element. You can also perform the reverse operation — inline a child element as an attribute of the parent tag.
This refactoring allows you to remove unneeded type qualifiers when the target type is already defined (for example, on a style setter) to improve code readability.
Use this refactoring to remove unused xmlns references.
You can run Move Type to Namespace and Rename Namespace to Match Folder Structure refactorings both in an XAML and XAML code behind file.
The following screencast shows the Move Type to Namespace refactoring run in XAML code-behind file:
For more information on refactorings, see Refactoring Assistance.
You can paste a piece of markup into your file and call the Import All Types code provider. This provider declares all namespace references used in the XAML file.
For more information on code providers, see Code Providers.
The Show Color feature adds a color preview to all colors you use in XAML code.
You can use the CodeRush Color Picker to edit a color. Click a preview stripe to invoke this editor.
This feature supplements your code with lines that highlight XAML markup structure.
CodeRush displays the region name on the closing tag.
For more information on CodeRush visualization features, see Visualization Tools.
You can surround the selected markup code with a tag or region.