1

我正在尝试在 XAML 中做我自己的滑块样式,但我不太正确。VisualState x:Name="Pressed"没有被触发。

...
<ControlTemplate TargetType="Slider">
    <Grid>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup Name="CommonStates">
                <VisualState Name="Normal" />
                <VisualState Name="MouseOver">
                    ...
                </VisualState>
                <VisualState Name="Pressed">
                    <Storyboard>
                        <ColorAnimation Storyboard.TargetName="RepeatButtonValueBrush" Storyboard.TargetProperty="Color" To="{StaticResource PressedValueColor}" Duration="0"/>
                        <ColorAnimation Storyboard.TargetName="RepeatButtonRestBrush" Storyboard.TargetProperty="Color" To="{StaticResource PressedTrackColor}" Duration="0"/>
                    </Storyboard>
                </VisualState>
                <VisualState Name="Disabled">
                    ...
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        ...
    </Grid>
</ControlTemplate>
...

我究竟做错了什么?

谢谢

4

1 回答 1

1

You need to call the VisualStateManager.GoToState method to change visual states. See this VisualStateManager and Triggers article.

于 2013-06-12T16:20:28.227 回答