滚动期间保持画布处于同一位置
我在缩放 wpf 画布控件时遇到一些问题。我使用 WPF 提供的 ScaleTransform 操作来缩放画布。问题是画布位置在缩放过程中发生变化。有没有任何有效(且简单)的方法可以在缩放操作期间保持滚动位置完整?我知道我每次都可以自己设置滚动位置,但效率很低
I have some problems with zooming wpf canvas control. I zoom canvas using ScaleTransform operation which is provieded by WPF. The problem is that canvas location is changing during zooming. Is there any efficient (and simple) way to keep the scroll position intact during zooming operation ?? I konow I could set a scroll position myself every time but it will be unefficient
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 LayoutTransform 代替 RenderTransform 怎么样?您没有提到您正在使用哪一个,但因为 LayoutTransform 没有改变位置,我猜您使用了后者。
How about using LayoutTransform instead of RenderTransform? You didn't mention which one you were using, but because LayoutTransform is not changing the position i guess you used the later.
我认为您正在寻找在缩放时保持滚动位置的东西,看看 > http://www.codeproject.com/KB/docview/WpfZoomAndDragPanel.aspx
I think you are looking for something that maintains scroll position while zooming, have a look at > http://www.codeproject.com/KB/docview/WpfZoomAndDragPanel.aspx
您需要设置ScaleTransform的CenterX和CenterY。这就是控制显示屏中间内容的方法,也是您保持缩放居中的方法。
You need to set the CenterX and CenterY of the ScaleTransform. That is what controls what's in the middle of the display and it's how you can keep your zoom centered.