简体   繁体   中英

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.

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. This will prevent ScrollViewer from handling MouseWheel event.

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.

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