在动画播放器之后保留样式 - WPF

时间:2018-02-09 01:05:23

标签: c# wpf xaml datagrid

我有一个带有几个按钮和文本的DataGrid。您可以单击这些按钮,如果符合条件,我会在整个DataGrid行中显示淡化颜色动画,表示事件成功,以及发生故障状态时:

<Storyboard x:Key="AnimationSuccessful">
    <ColorAnimation To="#22218ffe" 
                    Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)" 
                    FillBehavior="HoldEnd" 
                    Duration="0:0:0.3" />
</Storyboard>

<Storyboard x:Key="AnimationUnsuccessful">
    <ColorAnimation To="#00fe1f21" 
                    Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)" 
                    FillBehavior="HoldEnd" 
                    Duration="0:0:0.6"/>
</Storyboard>

此DataGrid也是一个通用的DataGridRow样式:

<Style TargetType="{x:Type DataGridRow}" x:Key="DefaultDataGridRow">
    <Setter Property="Foreground" Value="{StaticResource FG_Gray}"/>
    <Setter Property="Height" Value="35"/>
    <Setter Property="Background" Value="Transparent" />
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="{StaticResource BG_HL_Gray}" />
        </Trigger>
        <Trigger Property="IsSelected" Value="True">
            <Setter Property="Background" Value="{StaticResource BG_Selected_Gray}" />
        </Trigger>
    </Style.Triggers>
</Style>

这一切都有效,除了......

当您点击按钮并且“成功”&#39;或者&#39;不成功&#39;动画播放,基线风格永远不会再有效。

在对如何解决这个问题进行一些搜索之后,我想我已经决定尝试将动画作为EventTriggers连接到基线样式。但是,我不确定如何使用自定义RoutedEvent在运行时解决我想要播放动画的特定行。

这是正确的做法,还是有更好的方法来恢复&#39;事件发生后我的风格?

0 个答案:

没有答案