tags:

views:

150

answers:

2

For example I have an animation that triggers when mouse is clicked.

Problem is if you keep clicking the animation will restart.

I want to guarantee that an animation always plays through to completion.

Ideas?

+1  A: 

One trick I've found is to not include the "From" on my animations. That way the values will always start at whatever value the property you're animating has right now. That means that if the animation restarts, it won't reset the property back to its starting value and will instead look like it's continuing the orginal animation.

Matt Hamilton
This is also great for "reversing" animations (like in a mouseover/mouseout type scenario), not providing a start value means you can run your reverse animation from the current value and not from the "end".
Steven Robbins
Handoff animations are nice, but do not really answer my question. We have an animation that once started must run to completion.
Schneider
A: 

Still not the exact answer you are looking for, but this solved a problem I had involving a MouseDown trigger that started a new animation on top of a still running one:

<BeginStoryboard>
  <Storyboard AutoReverse="True">
    <ColorAnimation Storyboard.TargetProperty="(Label.Foreground).(SolidColorBrush.Color)"
                    To="Red" Duration="0:0:1"/>
  </Storyboard>

The problem with this animation is, that when it is triggered again before it completes, the autoreverse feature reverses it to the shade of red it had reached before it was triggered the second time, not to the original color it had before the first animation started.

In my case this was easily solved thus:

<BeginStoryBoard HandOffBehavior="Compose">
Dabblernl