I have the following code:
private Point initialpoint;
private void ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
initialpoint = e.Position;
}
private void ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
Point currentpoint = e.Position;
if (currentpoint.X - initialpoint.X >= 100)
{
System.Diagnostics.Debug.WriteLine("Swipe Right");
e.Complete();
}
}
I can handle 1 finger swipe gesture very easily, but I want to handle 2, 3, 4 fingers swipe gestures also. Can anyone tell me how to do that?
I adapted answer from Mark Hall to a separate class and to deal with swipes up, down, left and right. It still has problems where you can lift fingers at different times and get multiple events and could be improved, although it works for my needs:
Usage
According to this MSDN Forum Posting you will need to use pointer notifications. The documentation with working example code resides in the MSDN Library
From last link:
Just a caveat, I do not have a multitouch Windows 8 device to test this code on. So it has been tested in the Simuator with all of its limitations, and as mentioned in the above links Windows 8 doesn't not have built in gesture support for detecting multiple fingers you have to use lower level functions.
First of all I added two more dictionary's to the above MSDN example code and two variable for your Swipe Threshold to the Class definitions.
I then initialize the Dictionarys in the Form's Constructor
Then every place that the Original Dictionary was added to or had an item removed I did the same with the new Dictionary's
adding:
removing:
Then finally put them together in the PointerMovedEvent:
Final Modified MSDN Example: