Add Gestures to Your Windows Phone 7 Application

As it turns out, it is extremely easy to add gestures to your Windows Phone app. All you need to do is add a reference to the Silverlight Toolkit


xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

Then add the following code to any UI element (button, textbox etc...) that you want the gesture to be applied to and implement the listeners in your .cs file


<toolkit:gestureservice.gesturelistener>
     <toolkit:GestureListener 
         DoubleTap="GestureListenerDoubleTap"
         Hold="GestureListenerHold"/>
</toolkit:gestureservice.gesturelistener>

Last step is the implementation of the listeners:


private void GestureListenerDoubleTap(object sender, GestureEventArgs e)
{
    MessageBox.Show("Double tap gesture");
}

and


private void GestureListenerHold(object sender, GestureEventArgs e)
{
    MessageBox.Show("Hold gesture");
}

</p>

That's it. It is THAT simple

</center>