Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.
Pinch Gestures in Qt and Windows Phone
This article demonstrates how to handle pinch gestures in Qt and WP7.
- Input, Touch, and Gestures (MSDN)
First create an empty Windows Phone project. We need to download and install the Silverlight Toolkit, then add the reference Microsoft.Phone.Controls.Toolkit to the project. Next add the namespace in the XAML page.
Now we add the Image control in the XAML page
Then we add the GestureService.GestureListener to the Image control to handle gestures on it. We also add transformation to the Image. The GestureListener provides an easy way to detect touch gestures in our application. PinchStarted and PinchDelta events can be used together to detect if a user is performing any pinching operation, like zoom in or zoom out. On pinch start the OnPinchStarted() event handler is called and to detect any two-touch point operation OnPinchDelta() event handler is used.
private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
Scale = ((CompositeTransform)ImagePinchZoom.RenderTransform).ScaleX;
private void OnPinchDelta(object sender, PinchGestureEventArgs e)
var transform = (CompositeTransform)ImagePinchZoom.RenderTransform;
transform.ScaleX = Scale * e.DistanceRatio;
transform.ScaleY = transform.ScaleX;
This is a very basic way of gestures implementation in WP7. To know more about WP7 gestures please visit MSDN.
- The full source code of the example is available here: File:PinchGesturesWP7.zip