我正在处理的应用程序有一个surfacelistbox,我的滚动条正在尝试设置样式,但出于某种原因,我正在做的事情不会影响它。
风格:
<Style TargetType="s:SurfaceScrollBar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="s:SurfaceScrollBar">
<Grid x:Name="Root">
<Track Margin="2,6,6,6"
Name="PART_Track"
Grid.Row="1"
IsDirectionReversed="true">
<Track.DecreaseRepeatButton>
<s:SurfaceRepeatButton Command="ScrollBar.PageUpCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<s:SurfaceThumb Width="10"/>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<s:SurfaceRepeatButton Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="s:SurfaceRepeatButton">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="s:SurfaceRepeatButton">
<Border Background="Transparent"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type s:SurfaceThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="s:SurfaceThumb">
<Border CornerRadius="5"
Background="DimGray"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我已尝试将此样式放在app.xaml中,在窗口的资源中,以及列表框本身的资源(<s:SurfaceListBox.Resources>
)中,但没有任何视觉效果。但是,如果我将其更改为常规列表框并相应地更改样式(surfaceScrollBar到ScrollBar等),无论我把它放在哪里,样式都会被正确应用,但这会打破触摸滚动。
我对这个风格本身做错了吗?