在Xamarin Forms中,我们如何限制捏合手势仅在图像上缩放而不在整个屏幕上缩放?

我的XAML中包含以下内容,并认为将图像包装在PinToZoomContainer中可以完成此操作,但仍会缩放整个屏幕。

<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);
}

最佳答案

改正这个

public PinchToZoomContainer()
{
     var pinchGesture = new PinchGestureRecognizer();
     pinchGesture.PinchUpdated += OnPinchUpdated;
     bigImg.GestureRecognizers.Add(pinchGesture);
}

关于c# - Xamarin Forms-仅在图像而不是整个屏幕上使用捏手势,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49626806/

10-13 06:45