简体   繁体   English

如何在WPF中冻结ScrollViewer?

[英]How freeze the ScrollViewer in WPF?

i have a Canvas (WPF) where i can Zoom and Pan but when i want zoom in/zoom out the Canvas holding the key Ctrl + the wheel of MiddleButtonMouse in the same time also the ScrollViewer move up or down creating an undesirable effect so i ask you if there is a way meantime i zoom in/zoom out the Canvas and can make freezable the ScrollViewer without create that undesirable effect. 我有一个Canvas(WPF),可以进行缩放和平移,但是当我想同时按住Ctrl键和MiddleButtonMouse滚轮来放大/缩小Canvas时,ScrollViewer也会上下移动,因此产生了不良效果,所以我询问您是否有办法同时放大/缩小Canvas,并使ScrollViewer可冻结,而不会产生不良效果。

Thanks so much for attention 非常感谢您的关注

Cheers 干杯

Subscribe to the PreviewMouseWheel event of the ScrollViewer and do e.Handled = true when you don't need it to scroll. 订阅ScrollViewer的PreviewMouseWheel事件,并在不需要滚动时执行e.Handled = true。 This will prevent ScrollViewer from handling MouseWheel event. 这将防止ScrollViewer处理MouseWheel事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM