Wpf ScrollViewer 滚动量 [英] Wpf ScrollViewer Scroll Amount

查看:70
本文介绍了Wpf ScrollViewer 滚动量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改 WPF ScrollViewer 的滚动量?我只是想知道是否可以更改滚动查看器,以便在使用鼠标滚轮或滚动查看器箭头时可以更改增量滚动量.

Is it possible to change the amount that the WPF ScrollViewer scrolls? I am simply wondering if it's possible to change the scrollviewer so that when using the mouse wheel or the scrollviewer arrows, the amount of incremental scrolling can be changed.

推荐答案

简短的回答是:如果不编写一些自定义滚动代码,就无法做到这一点,但不要让这吓到您,这并不难.

The short answer is: there is no way to do this without writing some custom scrolling code, but don't let that scare you it's not all that hard.

ScrollViewer 要么通过使用物理单位(即像素)滚动,要么通过使用 IScrollInfo 实现来使用逻辑单位.这由设置 CanContentScroll 属性 其中 false 值表示使用物理单位滚动内容",true 值表示逻辑滚动内容".

The ScrollViewer either works by scrolling using physical units (i.e. pixels) or by engaging with an IScrollInfo implementation to use logical units. This is controlled by the setting the CanContentScroll property where a value of false means "scroll the content using physical units" and a value of true means "scroll the content logically".

那么 ScrollViewer 是如何逻辑地滚动内容的呢?通过与 IScrollInfo 实现通信.这就是当有人执行合乎逻辑的操作时,您可以准确控制面板内容滚动的方式.查看 IScrollInfo 的文档 获取可请求滚动的所有逻辑测量单位的列表,但既然您提到了鼠标滚轮,那么您最感兴趣的是 MouseWheelUp/Down/Left/Right 方法.

So how does the ScrollViewer scroll the content logically? By communicating with an IScrollInfo implementation. So that's how you could take over exactly how much the content of your panel scrolls when someone performs a logical action. Take a look at the documentation for IScrollInfo to get a listing of all the logical units of measurment that can be requested to scroll, but since you mentioned the mouse wheel you'll be mostly interested in the MouseWheelUp/Down/Left/Right methods.

这篇关于Wpf ScrollViewer 滚动量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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