Hello,
Welcome to Microsoft Q&A!
The button object has a DoubleTapped Event which will occur when the user double-taps the button. You could handle that event for your logic.
One thing you need to notice is that, If you want different logic for Tapped versus DoubleTapped, your Tapped handler may need to use app-specific variables and a timer in order to avoid running on interactions that are eventually interpreted as a DoubleTap action. This is mentioned in the official document here: UIElement.DoubleTapped Event Remarks.
So what you need to do looks like this:
<Button Content="Click" Tapped="MyButton_Tapped" IsDoubleTapEnabled="True" DoubleTapped="MyButton_DoubleTapped" Name="MyButton"/>
Code-behind:
public bool IsSingleTap;
private void MyButton_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
IsSingleTap = false;
Debug.WriteLine("MyButton_DoubleTapped");
}
private async void MyButton_Tapped(object sender, TappedRoutedEventArgs e)
{
IsSingleTap = true;
await Task.Delay(200);
if (IsSingleTap)
{
Debug.WriteLine("MyButton_Tapped");
}
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.