Click or drag to resize
DigitalRuneAnimationInstanceCompleted Event
Occurs when the animation has completed playing. Use with caution - see remarks.

Namespace: DigitalRune.Animation
Assembly: DigitalRune.Animation (in DigitalRune.Animation.dll) Version: 1.4.0.0 (1.4.1.14427)
Syntax
public event EventHandler<EventArgs> Completed

Value

Type: SystemEventHandlerEventArgs
Remarks

A root instance has completed playing when the root timeline has reached the end of its duration (including any repeats). A child instance is considered to have finished playing when the root instance has finished playing.

Important: The completion event does not trigger when animation is explicitly stopped or removed before it has reached the end of its duration. (But the completion event is triggered when the user sets the Time to a value past the end of the duration.)

The completion event is not raised immediately when the state of the animation changes. Instead, the AnimationManager records all animations that have finished playing in Update(TimeSpan) and explicitly raises the completion events in ApplyAnimations.

Use with Caution: The animation system uses weak references to ensure that animations do not accidentally keep the animated objects and properties alive. Animations are automatically removed if the animated objects are removed (i.e. garbage collected). But the Completed event stores the event handlers using a strong reference. If an event handler keeps the animation objects or properties alive, then the animation system will not be able to automatically remove the animation and the referenced resources. To ensure that all resources are properly freed, make sure that one of the following conditions is true:

  • The completion event handlers do not keep the target object or properties that are being animated alive.
  • The completion event handlers are removed explicitly if they are no longer required.
  • The animation is stopped explicitly when it is no longer needed, e.g. by calling Stop).
  • The animation is stopped implicitly, e.g. by starting a new animation which replaces it.
  • The animation has a limited duration and stops automatically. (The FillBehavior needs to be set to Stop.)

See Also