WPF: Animation Only Runs Once
Posted
by Phil Sandler
on Stack Overflow
See other posts from Stack Overflow
or by Phil Sandler
Published on 2010-04-30T14:30:56Z
Indexed on
2010/04/30
15:37 UTC
Read the original article
Hit count: 565
Very basic (I think) animation question. My animation only runs the first time "MyProp" gets set to false. If it gets set a second time, the animation doesn't run. I know my data trigger is getting hit, as the sound DOES play. The effect I want is for the animation to run, then reset the target property back to what it was before the animation occurred (thus the FillBehavior=Stop).
Do I need to reset the animation after it plays?
<DataTrigger Binding="{Binding MyProp}" Value="False">
<DataTrigger.EnterActions>
<SoundPlayerAction Source="/Resources/Sounds/Ding.wav"/>
<BeginStoryboard>
<Storyboard BeginTime="00:00:00" Duration="0:0:2"
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)">
<ColorAnimation FillBehavior="Stop" From="Black" To="Red" Duration="0:0:0.5" AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
© Stack Overflow or respective owner