In Visual Studio, how to quickly jump from the XAML binding path to the corresponding code?

I would like to be able to easily navigate from XAML code:

  <Binding Path="Duration">

to the corresponding C # code for the property:

  public static DependencyProperty DurationProperty =
     DependencyProperty.Register("Duration", typeof(int), typeof(MainWindow));

The closest I can do is go to the file containing the code and then do a text search. There seems to be a better way.

The answer probably already exists, but I have not yet received the right combination of keywords to find it.

+3
source share
3 answers

, , , , . Resharper navigate to member (ctrl + alt + shift + N IntelliJ) Duration, , Duration.

, - , - - Visual Studio .

+3

, , () . , , . VB XAML, , VS2010 Macro/Add In for "Run" "Run On" Visual Studio 2010

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics

' This is intended to be used as a quick & dirty "go to definition" for
' properties referenced in XAML. The idea is that you have something like:
'
'  <Binding Path="InterestRate">
'
' You click on the name and run the macro which looks for the current word
' in quotes ("InterestRate") which should match on something like:
'
' MainWindow.xaml.cs(41):  DependencyProperty.Register("InterestRate", ...
'
Public Module QuotedSearch
    Sub DoQuotedSearch()
        Dim Pattern As String
        DTE.ExecuteCommand("Edit.SelectCurrentWord")
        Pattern = """" & DTE.ActiveDocument.Selection.Text & """"
        DTE.ExecuteCommand("Edit.FindinFiles")
        DTE.Find.FindWhat = Pattern
        DTE.Find.Target = vsFindTarget.vsFindTargetFiles
        DTE.Find.MatchCase = True
        DTE.Find.MatchWholeWord = False
        DTE.Find.MatchInHiddenText = True
        DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
        DTE.Find.SearchPath = "Current Project"
        DTE.Find.SearchSubfolders = True
        DTE.Find.FilesOfType = "*.*"
        DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1
        DTE.Find.Action = vsFindAction.vsFindActionFindAll
        If (DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then
            Throw New System.Exception("vsFindResultNotFound")
        End If
    End Sub
End Module

- .

0

Just place the mouse cursor on the name of the method and click . F12

It will redirect you to the method defined in the file cs.

0
source

All Articles