更改 ScrollViewer 滚动条自动隐藏计时器的默认时间 [英] Change default time of auto-hide timer of ScrollViewer scrollbars
问题描述
当 ScrollViewer 有滚动条显示,并且光标在大约 3 秒内没有移动时,滚动条会自动隐藏.
When a ScrollViewer has scrollbars showing, and the cursor is not moved for around 3 seconds, the scrollbars auto hide.
有没有办法将该时间设置为比默认时间多或少?
Is there a way to set that time to more or less than the default time?
编辑
重现:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ScrollViewer Height="500" Width="500">
<Grid Background="Blue" Height="1000" Width="1000">
</Grid>
</ScrollViewer>
</Grid>
将光标移到 ScrollViewer 上以显示滚动条.让光标不动 3 秒,滚动条就会消失.我想将那 3 秒更改为 1.
Move the cursor over the ScrollViewer to show the scrollbar. Leave the cursor motionless for 3 seconds to see the scrollbar disappear. I want to change those 3 seconds to 1.
编辑 2
后续问题 - 为什么这个 ScrollViewer 的 ScrollBars 出现了两次?
Follow-up question - Why does this ScrollViewer's ScrollBars appear twice? .
推荐答案
我想我需要开始打破在评论中快速回答的习惯;
I suppose I need to start breaking the habit of doing quickie answers in comments anyway so;
来自上面的原始评论.Scrollbar
的控件样式模板在 VisualStateManager
部分嵌入了嵌套在各种状态中的淡入/淡出的 ThemeAnimation.
Carrying from the original comments above. The control style templates for Scrollbar
have embedded ThemeAnimation's for FadeIn/FadeOut nested in various states in the VisualStateManager
portion.
因为它们动画继承了顺序;
对象 -> 依赖对象 -> 时间线
Object -> DependencyObject -> Timeline
...它们确实支持依赖属性,例如 BeginTime
和 Duration
,允许我们更改其操作的默认行为.因此,为了解决您的情况,您可以选择在 VisualStateManager
中将它们从各自的状态中完全删除,或者您可以更改属性以更好地满足您自己的时间线要求.
...they do support Dependency Properties such as BeginTime
and Duration
that allows us to alter the default behavior of their action. So to remedy your scenario you have the options of either removing them entirely from their respective states within the VisualStateManager
or you can alter the properties to better suit your needs of your own timeline requirements.
这样做只是使用 VS 或 Blend 提取控件模板,并将更改显式应用于模板副本或全局覆盖默认值.
Doing this is just a matter of extracting the control template using either VS or Blend and either applying changes explicitly to a copy of the template or overriding the default globally.
很高兴您找到了治疗方法.:)
Glad you found your remedy. :)
这篇关于更改 ScrollViewer 滚动条自动隐藏计时器的默认时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!