Visual Studio 2019 F12 Goto definition not working with CallMethodAction

Paul Mc 1 Reputation point
2021-07-07T13:18:54.993+00:00

I have a button on my WPF screen (xaml below). When I press F12 on the CallMethodAction MethodName (BtnLoginClick) it says "cannot navigate to definition" If I press F12 on the Content (ButtonText) it navigates to the property in my viewmodel cs file. Is there some option/setting to make the F12 navigation work for the CallMethodAction?

<Button
Content="{Binding ButtonText}"
d:Content="Login"
Grid.Row="3"
x:Name="BtnLogin"
Width="120"
HorizontalAlignment="Left">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:CallMethodAction MethodName="BtnLoginCick" TargetObject="{Binding}" >
</i:CallMethodAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,781 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
812 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 54,401 Reputation points
    2021-07-07T13:56:44.017+00:00

    I think you should report this via Visual Studio's Report an Issue but I suspect it is by design. It also depends on whether you're using the original WPF designer or the new one.

    The problem is that you're clicking an arbitrary attribute value on an arbitrary XAML element. The designer has no way of knowing that MethodName is actually pointing to a method and therefore GTD should work. I suspect therefore that it doesn't have enough context to correctly jump. This is probably solvable in the designer but not implemented.

    For your working case you are using the Binding expression. This is universal to XAML and therefore the designer is probably set up to support GTD when using a binding expression. It might also be coded for other commonly used XAML expressions but likely not for specific XAML elements.

    Again, report the problem via Visual Studio and let the team respond back. At worst they will ask you to report it as a suggested feature instead of a problem.

    0 comments No comments

  2. Shaista Altaf 1 Reputation point
    2021-08-06T05:18:58.447+00:00

    Solution that works for me in visual studio just
    go to Debug>options>IntelliCode>IntelliCode suggestions intent detect = Enabled
    Previously it was default

    121016-image.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.