question

PaulMc-5324 avatar image
0 Votes"
PaulMc-5324 asked ShaistaAltaf-8164 answered

Visual Studio 2019 F12 Goto definition not working with CallMethodAction

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-wpfdotnet-wpf-xaml
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


As a workaround, place the caret on "BtnLoginCick", press <Ctrl+,> and <Enter>.


0 Votes 0 ·
cooldadtx avatar image
0 Votes"
cooldadtx answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ShaistaAltaf-8164 avatar image
0 Votes"
ShaistaAltaf-8164 answered

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



image.png (73.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.