StopStoryboard in DataTrigger.EndActions
Posted: 21 Dec 2015, 16:28
I am writing a style containing a DataTrigger that will animate on certain states.
Right now, when leaving the state, the animation will not stop. I have tried including a StopStoryboard action in my DataTrigger.EndActions block, but no luck. Am I doing something wrong here?
Right now, when leaving the state, the animation will not stop. I have tried including a StopStoryboard action in my DataTrigger.EndActions block, but no luck. Am I doing something wrong here?
Code: Select all
<Style x:Key="MyStyle" TargetType="{x:Type common:MyComponent}">
<Style.Triggers>
<DataTrigger Binding="{Binding State}" Value="Done">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="Doing">
<Setter Property="Background">
<Setter.Value>
<RadialGradientBrush x:Name="RadialGradient" >
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="{StaticResource Color.Active.Bright.Normal}" Offset="1.5"/>
</RadialGradientBrush>
</Setter.Value>
</Setter>
<DataTrigger.EnterActions>
<BeginStoryboard x:Name="FlashingAnimation">
<Storyboard>
<DoubleAnimation x:Name="xAnimation"
Storyboard.TargetProperty="Background.RadiusX"
From="5" To="1" Duration="0:0:1" AutoReverse="True"
RepeatBehavior="Forever" />
<DoubleAnimation x:Name="yAnimation"
Storyboard.TargetProperty="Background.RadiusY"
From="5" To="1" Duration="0:0:1" AutoReverse="True"
RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<StopStoryboard BeginStoryboardName="FlashingAnimation"/>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>