如何在DataTrigger.ExitActions中重置背景颜色?

时间:2014-03-20 12:35:00

标签: wpf xaml

如何在DataTrigger.ExitActions中重置背景颜色?下面将它设置为红色,但在删除时我希望它重置为白色。感谢

            <Grid Name="cell" Background="White">
                <Grid.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding DataItem.ResultText, Converter={StaticResource IsNotNullOrEmptyConverter}}" Value="True">
                                <DataTrigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard x:Name="Blink">
                                            <ColorAnimation Storyboard.TargetProperty="Background.Color" To="Red" 
                                                            RepeatBehavior="3x" Duration="0:0:1" AutoReverse="True"/>
                                            <ColorAnimation Storyboard.TargetProperty="Background.Color" To="Red" 
                                                            Duration="0:0:1" BeginTime="0:0:4"/>
                                        </Storyboard>
                                    </BeginStoryboard>

                                </DataTrigger.EnterActions>
                                <DataTrigger.ExitActions>
                                    <RemoveStoryboard BeginStoryboardName="Blink" />
                                </DataTrigger.ExitActions>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding DataItem.ResultText, Converter={StaticResource IsNotNullOrEmptyConverter}}" Value="True">
                                <Setter Property="Grid.ToolTip" Value="{Binding DataItem.ResultText}" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>  

1 个答案:

答案 0 :(得分:0)

为什么你不做这样简单的事情

<DataTrigger.EnterActions>
    <BeginStoryboard>
        <Storyboard>
            <ColorAnimation Storyboard.TargetProperty="Background.Color" To="Red" 
                    RepeatBehavior="3x" Duration="0:0:1" AutoReverse="True"/>
            <ColorAnimation Storyboard.TargetProperty="Background.Color" To="Red" 
                    Duration="0:0:1" BeginTime="0:0:4"/>
        </Storyboard>
    </BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
    <BeginStoryboard>
        <Storyboard>
            <ColorAnimation Storyboard.TargetProperty="Background.Color" To="White" />
            <ColorAnimation Storyboard.TargetProperty="Background.Color" To="White"/>
        </Storyboard>
    </BeginStoryboard>
</DataTrigger.ExitActions>