【发布时间】:2023-04-02 09:36:01
【问题描述】:
如何从后面的代码中设置滚动条宽度?我在这篇文章 (How to increase scrollbar width in WPF ScrollViewer?) 中找到了一些示例,但仅在 XAML 中,而不是在动态中。
对我来说重要的是我能够在程序运行时更改滚动条的宽度。所以无论我做什么,都必须可以一遍又一遍地更新值。
<Style TargetType="{x:Type ScrollBar}">
<Setter Property="Stylus.IsFlicksEnabled" Value="True" />
<Style.Triggers>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Height" Value="40" />
<Setter Property="MinHeight" Value="40" />
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="40" />
<Setter Property="MinWidth" Value="40" />
</Trigger>
</Style.Triggers>
或
<Application
xmlns:sys="clr-namespace:System;assembly=mscorlib"
...
>
<Application.Resources>
<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">50</sys:Double>
<sys:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarHeightKey}">50</sys:Double>
</Application.Resources>
【问题讨论】:
标签: c# wpf resources scrollbar