I can easily handle 1 finger Tapped
, DoubleTap
and Holding
gestures like this:
public MainPage()
{
this.InitializeComponent();
this.Tapped += mc_Tapped;
this.DoubleTapped += mc_DoubleTapped;
this.Holding += mc_Holding;
}
public void mc_Tapped(object sender, TappedRoutedEventArgs e)
{
//Tap
}
public void mc_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
//DoubleTap
}
public void mc_Holding(object sender, HoldingRoutedEventArgs e)
{
//Hold
}
But the events don't have a property to get the number of fingers and they don't even get fired when more than 1 touch contact is present on the screen. I also want to handle 2, 3, 4, 5 fingers Tapped
, DoubleTap
and Holding
gestures. Can anyone tell me how to do that?
You'll have to work with the PointerRoutedEventArgs that are passed on Pointer events (ie. Pressed, entered, released and such) and do it the hard way
Each time pointer enters the control is assigned a unique pointer ID.I would create a Dictionary and add each pointer to that dictionary as it is pressed on the control (and obviously remove them when they exit). Then in your existing tapped, double tapped and such handlers just check how many pointers are in your dictionary and call the appropriate handlers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With