Xamarin.Forms Zoom an Image with the Pinch gesture


In order to make an Image (or any other visual element) zoomable we have to add a PinchGestureRecognizer to it. Here is how to do it in code:

var pinchGesture = new PinchGestureRecognizer();
pinchGesture.PinchUpdated += (s, e) => {
// Handle the pinch

But it can also be done from XAML:

<Image Source="waterfront.jpg">
    <PinchGestureRecognizer PinchUpdated="OnPinchUpdated" />

In the accompanied event handler you should provide the code to zoom your image. Of course other uses can be implement as well.

void OnPinchUpdated (object sender, PinchGestureUpdatedEventArgs e)
    // ... code here

Other gestures are Tap and Pan.