1

I have some problems with stopping my animation, it just goes on forever. I would think that the RepeatBehavior should control this, but it does not seem to work.

<Grid.Style>
    <Style TargetType="Grid">
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsNew}" Value="true">
                <DataTrigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation RepeatBehavior="1"
                                Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
                                To="LightGreen" Duration="0:0:0.25" AutoReverse="True" >
                            </ColorAnimation>
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
            </DataTrigger>
            <DataTrigger Binding="{Binding IsNew}" Value="false">
                <Setter Property="Background" Value="WhiteSmoke"></Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Grid.Style>
4

1 回答 1

3

解决方案是使用

RepeatBehavior="1x"

所以1x不仅仅是1,对我来说不是很合乎逻辑,但可能是有原因的..

更新(在@clemens 输入后):

根据 MSDN,XAML 属性用法是:

<object property="iterationCountx"/>
- or -
<object property="[days.]hours:minutes:seconds[.fractionalSeconds]"/>
- or -
<object property="[days.]hours:minutes"/>
- or -
<object property="days"/>
- or -
<object property="Forever"/>

这更有意义,但不是很直观..

<Grid.Style>
    <Style TargetType="Grid">
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsNew}" Value="true">
                <DataTrigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation RepeatBehavior="1x"
                                Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
                                To="LightGreen" Duration="0:0:0.25" AutoReverse="True" >
                            </ColorAnimation>
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
            </DataTrigger>
            <DataTrigger Binding="{Binding IsNew}" Value="false">
                <Setter Property="Background" Value="WhiteSmoke"></Setter>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Grid.Style>
于 2013-10-15T12:42:36.757 回答