WPF - 增加现有样式的滚动条宽度(WPF - Increase scrollbar width of existing style)

我目前正在使用MahApps.Metro来设置我的WPF控件的样式。 当我向组件添加ScrollViewer时,使用了MahApps.Metro样式,但是当我喜欢这种样式时,滚动条的宽度(垂直)不适合我的需要。 有人可以建议一种方法来增加现有样式的宽度(从库中,虽然源在github上可用)?

我尝试过使用:

<Style TargetType="ScrollBar"><Setter Property="Width" Value="50"/></Style>

但它将MahApps.Metro样式恢复为WPF默认值,但使用较粗的滚动条。 在此之后,我尝试使用:

<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">100</sys:Double>

但它似乎没有视觉效果。

MahApps.Metro网站 MahApps.Metro Github

I'm currently using MahApps.Metro to style my WPF controls. When I add a ScrollViewer to components the MahApps.Metro style is used, but while I like the style, the width of the scrollbar (vertical) isn't suitable for my needs. Could someone suggest a way to increase the width of an existing style (from a library, although source is available on github)?

I've tried using:

<Style TargetType="ScrollBar"><Setter Property="Width" Value="50"/></Style>

but it reverts the MahApps.Metro style back to the WPF default, but with thicker scrollbars. After this, I tried using:

<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">100</sys:Double>

but it seemed to have no visual effect.

MahApps.Metro Website MahApps.Metro Github

最满意答案

看起来他们的ScrollBar样式使用不同的资源键覆盖宽度和高度:

<Style.Triggers> <Trigger Property="Orientation" Value="Horizontal"> <Setter Property="Height" Value="{DynamicResource MetroScrollBarHeight}" /> <!-- ... --> </Trigger> <Trigger Property="Orientation" Value="Vertical"> <Setter Property="Width" Value="{DynamicResource MetroScrollBarWidth}" /> <!-- ... --> </Trigger> </Style.Triggers>

尝试像以前一样放弃资源覆盖,但改为使用自定义资源键:

<sys:Double x:Key="MetroScrollBarWidth">100</sys:Double>

It looks like their ScrollBar style overrides the width and height with different resource keys:

<Style.Triggers> <Trigger Property="Orientation" Value="Horizontal"> <Setter Property="Height" Value="{DynamicResource MetroScrollBarHeight}" /> <!-- ... --> </Trigger> <Trigger Property="Orientation" Value="Vertical"> <Setter Property="Width" Value="{DynamicResource MetroScrollBarWidth}" /> <!-- ... --> </Trigger> </Style.Triggers>

Try dropping in a resource override like you did before, but use their custom resource key instead:

<sys:Double x:Key="MetroScrollBarWidth">100</sys:Double>

更多推荐

MahApps,Metro,使用,style,样式,电脑培训,计算机培训,IT培训"/> <meta name="des