In Xamarin Forms, how do we restrict the pinch gesture to zoom only on an image rather than the entire screen?
I have the following in my XAML and thought that wrapping my image in the PinToZoomContainer would do it but it still zooms the whole screen.
<local:ContentRatioContainer>
<local:PinchToZoomContainer>
<local:PinchToZoomContainer.Content>
<Image Aspect="AspectFill" Source="{Binding PreviewImage}" AbsoluteLayout.LayoutBounds="1,1,1,1" AbsoluteLayout.LayoutFlags="All" x:Name="bigImg" >
<Image.GestureRecognizers>
<PinchGestureRecognizer PinchUpdated="OnPinchUpdated" />
</Image.GestureRecognizers>
</Image>
</local:PinchToZoomContainer.Content>
</local:PinchToZoomContainer>
</local:ContentRatioContainer>
public PinchToZoomContainer()
{
var pinchGesture = new PinchGestureRecognizer();
pinchGesture.PinchUpdated += OnPinchUpdated;
GestureRecognizers.Add(pinchGesture);
}
Correct this by,
public PinchToZoomContainer()
{
var pinchGesture = new PinchGestureRecognizer();
pinchGesture.PinchUpdated += OnPinchUpdated;
bigImg.GestureRecognizers.Add(pinchGesture);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.