Поделиться через


Repeating an animation

It may not be a huge revelation for other folks, but with some of the testing I've been doing, I really started getting frustrated with some stuff.

Specifically, I've got a fairly complex animation, and I want it to repeat forever. However, setting the repeat count on each and every property that I'm animating is rather tedious. "Set the repeat count on the X Rotation... set the repeat count on the Y Rotation... set the repeat count on the X Skew... *sigh*... Set the repeat count on the Y Skew..." etc...

Now, you can't set the repeat count on a composite keyframe in the hopes that the RepeatCount will be propogated downward inside Blend (Yes, I've asked my PMs for that feature, and MAYBE it will make it into the product some day, but who knows...).

So, how do you handle this? Now, I'm sure the XAML experts already knew this, but if you go into the XAML, you can just add RepeatBehavior="Forever" to the Storyboard. The XAML now looks like:

<Window.Resources>
  <Storyboard x:Key="Timeline1" RepeatBehavior="Forever">

And that's it. Now, the animation will start at the beginning, run until the time when all the existing animations have ended, then start over again.

Again, most of the XAML folks probably already knew this, but I thought it was pretty cool.

Comments