I have a sequence of animations I want to execute one after another, how do I do that?
Note that in WPF all animations (element.BeginAnimation method) are executed asynchronously. So, if you call a bunch of BeginAnimation methods one after another in a for loop, they all will overlap and not really execute one after another.
There is really no way to chain animations in WPF. You will have to basically listen to an animation’s Completed event and then trigger the next animation. To make such code efficient and scalable I came up with this recursion with in-line event handler based approach:
Let us say you want to increase the width of these 2 rectangles one after the other via animation:
The code-behind for this would be:
The idea is to maintain a list of "animation definitiions" and execute animations from this list recursively.