设置滚动条拇指大小 [英] Setting the Scrollbar Thumb size
问题描述
我正在尝试制定与 WPF 滚动条拇指元素大小相关的算法.
I am attempting to work out the algorithm associated with sizing of the WPF Scrollbar thumb element.
可以使用 Scrollbar.ViewportSize
属性调整 thumb 元素的大小,但它又与 Scrollbar.Minimum
和 Scrollbar.Maximum代码>值.
The thumb element can be sized using the Scrollbar.ViewportSize
property, but it in turn is related to the Scrollbar.Minimum
and Scrollbar.Maximum
values.
到目前为止我发现的是:
What I have discovered so far is:
对于 0 和 10 的最小值和最大值,ViewportSize 为:
For a Minimum and Maximum of 0 and 10, a ViewportSize of:
0 - 拇指最小尺寸
5 - 拇指大约 25% 的可用曲目
10 - 拇指大约 50% 的可用曲目
100 - 拇指大约 75% 的可用曲目
1000 - 拇指大约 90% 的可用曲目
10000 - 拇指填满可用的轨道.
0 - Thumb minimum size
5 - Thumb approximately 25% of the available track
10 - Thumb approximately 50% of the available track
100 - Thumb approximately 75% of the available track
1000 - Thumb approximately 90% of the available track
10000 - Thumb fills the available track.
[注意:这些数字只是我粗略的尝试和错误!]
[note: these figures are only from my rough trial and error!]
理想情况下,我希望能够有一个算法,在给定滚动条的最小值和最大值的情况下,我可以将拇指大小设置为可用轨道的 x%.
Ideally I'd like to be able to have an algorithm where given the minimum and maximum values for the Scrollbar I can set the thumb size to be exactly x% of the available track.
有人可以帮忙吗?
谢谢.
推荐答案
来自:http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.track(VS.90).aspx
拇指大小 =(viewportSize/(maximum–minimum+viewportSize))×trackLength
thumbSize = (viewportSize/(maximum–minimum+viewportSize))×trackLength
或重新安排viewportSize:
or re-arranging for viewportSize:
视口大小 =thumbSize×(maximum-minimum)/(trackLength-thumbSize)
viewportSize = thumbSize×(maximum-minimum)/(trackLength-thumbSize)
你可能已经找到了这个,但我想我会发布以防其他人在这里结束.
You've prob found this already but thought I'd post in case others end up here.
这篇关于设置滚动条拇指大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!