.NET MAUI › Gestures & Animations

How do you implement pinch-to-zoom or pan in MAUI?

Intermediate

Answer

Attach a PinchGestureRecognizer and update Scale from e.Scale around the pinch origin, or a PanGestureRecognizer and update TranslationX/Y from e.TotalX/Y. Track the starting transform in the Started status and apply deltas during Running to keep motion smooth.
void OnPan(object s, PanUpdatedEventArgs e)
{
    if (e.StatusType == GestureStatus.Running)
    {
        image.TranslationX = _startX + e.TotalX;
        image.TranslationY = _startY + e.TotalY;
    }
}
Real-world example An image editor lets users pan a zoomed photo by tracking pan deltas from the gesture start point.

Common follow-ups: Why track the start transform? | How do you zoom around the pinch point?