2

Is there a possibility to register a function to a Animated Usercontroll that is called when the animation is over?

I have a Usercontroll-Animation I start by calling .BeginAnimation(propdp, animation);

How to call another function when the Animation is over?

marcel
  • 3,231
  • 8
  • 43
  • 76
  • Unfortunately the users named below have voted to close your question because they incorrectly assumed that your problem was the same as the post mentioned at the top of your question. I have voted to re-open it, but more votes are needed... come on StackOverflow community... see some sense here please and re-open this question. – Sheridan Nov 26 '13 at 15:46
  • 1
    @Sheridan Maybe you should point out what this question makes different from the other - in particular because the answer of afore-mentioned question exactly contains the code snippet to be used. It even links the same documentation than you did. – JeffRSon Nov 26 '13 at 16:25
  • +1 @JeffRSon, you are completely correct and I was mistakenly looking at a different question that was `Storyboard` based. I accept that this question is the same as the linked question and retract my previous comment. Thank you for coming back to point that out. – Sheridan Nov 26 '13 at 16:42

2 Answers2

7

There is a Timeline.Completed Event that you can use. You can either set it in XAML, or in C# on a Storyboard instance. The linked page has a full working example that you can view.

The handler used is the default EventHandler delegate:

private void StoryboardCompleted(object sender, EventArgs e)
{
    // the Storyboard has stopped
}

UPDATE >>>

Although the Completed event can be set on a Storyboard instance, it is in fact defined in the Timeline class. As Timeline is the base class for all AnimationTimeline classes, this means that you can also attach a handler to the Completed event from the AnimationTimeline object that you are passing into the BeginAnimation event.

Sheridan
  • 68,826
  • 24
  • 143
  • 183
  • What can I do if I don't have a storyboard? The example needs a reference to a storyboard I guess. – marcel Nov 26 '13 at 15:08
  • Didn't find the post I duplicated, before I created this. sry. Anyway, the completed event works fine. thx to JeffRSon as well :) – marcel Nov 27 '13 at 10:50
0

There is an animation.Completed event.

JeffRSon
  • 10,404
  • 4
  • 26
  • 51