How to: Rename a Symbol that is Declared in XAML
Starting with Visual Studio 2008 SP1, you can rename a symbol that is declared in XAML by using the Windows Presentation Foundation (WPF) Designer for Visual Studio. You can also change the x:Class definition of a class that is declared in XAML.
Note
Visual Basic does not have a default refactor mechanism similar to Visual C#.
To rename a symbol declared in XAML
Create a new WPF Application project in Visual C# named WPFApplication1. For more information, see How to: Create a New WPF Application Project.
Window1.xaml opens in the WPF Designer.
In XAML view, replace the default <Grid> element with the following text.
<Grid x:Name="grid1"> </Grid>
In XAML view, right-click and select View Code from the context menu.
The Code Editor opens the code-behind file.
In the Code Editor, insert the following line in the Window1 class constructor.
this.grid1.AllowDrop = true;
Right-click grid1, point to Refactor, and select Rename from the context menu.
The Rename dialog box opens.
Type _grid in the New name: text box and click OK.
The Preview Changes - Rename dialog box opens.
Click Apply.
The symbol grid1 is renamed to _grid.
Right-click _grid and select Go To Definition from the context menu.
XAML view opens with the cursor in the <Grid> element named _grid.
To change the x:Class definition
Add a WPF User Control item to the project. Name the control UserControl1.xaml. For more information, see How to: Add New Items to a WPF Project.
In XAML view, right-click and select View Code from the context menu.
The Code Editor opens the code-behind file.
Highlight the UserControl1 class name and right-click. In the context menu, point to Refactor, and select Rename.
The Rename dialog box opens.
Type MediaElement in the New name: text box and click OK.
The Preview Changes - Rename dialog box opens.
Click Apply.
Right-click the MediaElement class name and select Go To Definition from the context menu.
XAML view opens with the caret in the <UserControl> element. The x:Class assignment reads x:Class="WpfApplication1.MediaElement".