Reputation: 2763
I am using a pivot page in my wp7 application. The PivotItems are added programatically. I need to get events of all the gestures. How can I get them?
And, how to know the direction of flick gesture? After swiping how to get details of the current item.
I was trying this : WP7: Questions regarding Touch Gestures. But could not add
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="GestureListener_Flick" />
</toolkit:GestureService.GestureListener>
when I am trying to add this, an error occurs.
How can I get gesture events?
Upvotes: 0
Views: 1324
Reputation: 317
There is additional support for detecting touch in the XNA library. Trying adding the Microsoft.Xna.Framework.Input.Touch reference to your project
Include the following using statement:
using Microsoft.Xna.Framework.Input.Touch;
Subscribe to the required events in your constructor as follows:
TouchPanel.EnabledGestures = GestureType.Tap | GestureType.Flick;
On your control create an event for Manipulation Completed as follows:
ManipulationCompleted="Object_ManipulationCompleted"
You could add code to the that event method to track the type of events that have been completed with the following code:
private void Object_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
while (TouchPanel.IsGestureAvailable)
{
GestureSample gesture = TouchPanel.ReadGesture();
if (gesture.GestureType == GestureType.Tap)
{
//Do something
}
if (gesture.GestureType == GestureType.Flick)
{
//The delta contains the direction of the flick (negative/positive)
//gesture.Delta.Y;
//gesture.Delta.X;
}
}
}
Hope this Helps
Upvotes: 3