我已经覆盖了滚动条的默认模板。它只是一个矩形和一个箭头图片。我有 2 张图片,一张用于正常状态,一张用于 MouseOver。
在我的 VisualStates 中,我更改了 MouseOver 上的图像可见性。
当我现在使用鼠标over
滚动条时,它什么也不做,但是当我click
使用图像时,它正在从 NormalPicture 变为 HoverPicture。
我究竟做错了什么?
ScrollBarStyle:
<Style x:Key="ScrollBarStyle" TargetType="ScrollBar">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollBar">
<Grid x:Name="Root">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="NormalState">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="HoverState">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="VerticalRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Stroke="#00000000" StrokeThickness="1" Fill="Black" />
<Image x:Name="NormalState" Source="/SlDragDropTest;component/Images/ArrowUpNormal.png"></Image>
<Image x:Name="HoverState" Source="/SlDragDropTest;component/Images/ArrowUpHover.png" Visibility="Collapsed"></Image>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>