In my code, I am reading the movement of a finger within a specified area using PanGestureRecognizer
. However, I encountered an issue where the PanGestureRecognizer
event is not triggered when tapping twice, as TapGestureRecognizer
interferes with it. My question is how to resolve this issue.
To make the problem more understandable, I have a video to demonstrate the issue.
code:
<Border>
<Border.GestureRecognizers>
<PanGestureRecognizer PanUpdated="Touchpad_PanUpdate"/>
</Border.GestureRecognizers>
</Border>
back:
private void Touchpad_PanUpdate(object sender, PanUpdatedEventArgs e)
{
if (e.StatusType == GestureStatus.Running)
{
DebugRunningLabel.Text = "x/y: " + Math.Round(e.TotalX, 2) + " " + Math.Round(e.TotalY, 2);
}
}
Tapping twice on the screen is not related with the PanGestureRecognizer, it's related with TapGestureRecognizer. You can't mix them together.
If you want to make a View recognize a tap gesture with double taps, you can create a TapGestureRecognizer object, handle the Tapped event, set
NumberOfTapsRequired="2"
and add the new gesture recognizer to the GestureRecognizers collection on the view.The following code example shows a TapGestureRecognizer attached to an Image with tapping twice:
XAML:
C#: