使用ScrollViewer进行图像缩放时,可以保持向左平移 [英] Using ScrollViewer for image pinch-zoom, keeps snapping left on pan

查看:91
本文介绍了使用ScrollViewer进行图像缩放时,可以保持向左平移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用XAML ScrollViewer便宜地"将捏缩放添加到图像.但是,问题在于,在图像周围平移时,图像始终保持最靠左.如果我向右滑动它,看起来不错,但是第二次释放图像时,它会向左对齐.

I am trying to use a XAML ScrollViewer to 'cheaply' add pinch-zooming to an image. The issue however is that when panning around the image, it keeps snapping to the very left. If I slide it right, it looks fine, but the second I release the image, it snaps back to the left.

此问题仅在水平方向上仍然存在-对于垂直平移,它可以正常工作.

This problem only persists horizontally - for vertical panning, it works fine.

我将其抽象为最简单的测试用例,并且一直存在.我的XAML代码如下:

I abstracted this to the most simple test case, and it persists. My XAML code is as follows:

    <ScrollViewer>
        <Image Source="http://i.imgur.com/1WlGT.jpg" />
    </ScrollViewer>

感谢您的帮助.

推荐答案

我已经解决了这个问题.

I've resolved this.

问题是您必须明确将Horizo​​ntalScrollBarVisibility设置为true.

The issue is you have to explicityl set HorizontalScrollBarVisibility to true.

<ScrollViewer x:Name="scrollViewer" 
                  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" 
                  ZoomMode="Enabled">
        <Image Source="http://i.imgur.com/1WlGT.jpg" />
    </ScrollViewer>

这篇关于使用ScrollViewer进行图像缩放时,可以保持向左平移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆