Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 8 / XAML Double Tap event always preceded by Tap

I've got a button in an app. I want it to do different things depending on whether I tap it (pause an animation) or double-tap (restart the animation)

however, when I double-tap, it seems to fire the tap event first and then the double-tap in quick succession. Is there a way around this? Is this a known issue or am I making a rookie mistake?

Edit: For those asking, I'm using the Tapped and DoubleTapped events.

like image 905
roryok Avatar asked Nov 13 '12 12:11

roryok


1 Answers

Give the some pause to single tab . If there is double tab occur then single tab event eliminated

  bool singleTap;
    private async void control_Tapped_1(object sender, TappedRoutedEventArgs e)
    {
        this.singleTap = true;
        await Task.Delay(200);
        if (this.singleTap)
        {
              // Single tab Method .
        }
    }

    private void control_DoubleTapped_1(object sender, DoubleTappedRoutedEventArgs e)
    {
        this.singleTap = false;

        // Double tab Method  
  }
like image 171
Rahul Tripathi Avatar answered Oct 11 '22 13:10

Rahul Tripathi