WPF使用RepeatBehavior停止彩色动画
我有一些问题,停止我的动画,它只是永远继续下去。我认为RepeatBehavior应该控制这一点,但它似乎不起作用WPF使用RepeatBehavior停止彩色动画,wpf,animation,Wpf,Animation,我有一些问题,停止我的动画,它只是永远继续下去。我认为RepeatBehavior应该控制这一点,但它似乎不起作用 <Grid.Style> <Style TargetType="Grid"> <Style.Triggers> <DataTrigger Binding="{Binding IsNew}" Value="true"> <DataTrigger.Ent
<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>
解决方案正在使用
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>
原因很简单:RepeatBehavior=“1”
指定一天,而RepeatBehavior=“1x”
指定一次。您可能想看一下。@Clemens谢谢您的输入。我更新了答案并加入了MSDN代码。