Udostępnij za pośrednictwem


How to: Go to the Definition of an Object in XAML

There are a variety of ways to go to the definition of an object in XAML by using the WPF Designer for Visual Studio. This topic describes several ways.

To go to the definition of a control in the WPF Designer

  • Select the control in Design view.

    The control definition is highlighted in XAML view.

To go to the definition of a control from the code-behind file

  • In the Code Editor, right-click the control's symbol and select Go To Definition from the context menu.

    The control definition is highlighted in XAML view.

To go to the definition of a control from the Object Browser

  1. From the View menu, select Object Browser.

    The Object Browser window opens.

  2. Locate your project in the Object Browser.

  3. Expand the nodes until you find the class where the control is defined.

  4. Select the class.

    The control appears in the right pane of the Object Browser.

  5. In the right pane, double-click the control.

    The control definition is highlighted in XAML view.

To view the definition of a control in the Code Definition window

  1. From the View menu, select Code Definition Window.

  2. In the Code Editor, click the control's symbol.

    The control definition appears in the Code Definition Window.

Note

This feature is not available in Visual Basic.

To go to the definition of a control from the tag navigator

  • In XAML view, use the tag navigator at the bottom of the view to find the control.

    The control definition is highlighted in XAML view.

To view all the references to a control

  • In the Code Editor, right-click the control's symbol and select Find All References from the context menu.

    All references to the control are listed in the Find Symbol Results window.

To go to the definition of a control from the Class View window

  1. From the View menu, select Class View.

    The Class View window opens.

  2. Locate your project in the Class View window.

  3. Expand the nodes until you find the class where your control is defined.

  4. Select the class.

    The control will appear in the bottom pane of the Class View window.

  5. In the bottom pane, double-click the control.

    The control definition is highlighted in XAML view.

To go to the definition of an object by using the Document Outline window

  1. From the View menu, point to Other Windows and then select Document Outline.

    The Document Outline window opens.

  2. Browse the document outline until the object is found.

  3. Click the object in the Document Outline window.

    The object definition is highlighted in XAML view.

To go to the definition of an object by the object's name

  1. From the Edit menu, point to Find and Replace, and then select Quick Find.

    The Find and Replace window opens.

  2. Type the name of the object you want to find in the Find what: box and then click Find Next.

  3. If necessary, continue to click Find Next until the object is found.

    The object definition is highlighted in XAML view.

To go to the definition of a resource from the Properties window

  1. Select a control and view its properties in the Properties window.

  2. Click the property marker for a property and choose Go to Value Definition to navigate to the definition of the resource. The following illustration shows an example.

    SL_DesignerValueDef

See Also

Concepts

Split View: Viewing the WPF Design Surface and XAML at the Same Time

Navigating the Element Hierarchy of a WPF Document

Other Resources

XAML and Code in the WPF Designer

Change History

Date

History

Reason

March 2011

Added information about Go to Value Definition.

Information enhancement.