WPF SDK Release Notes: Clean Your Clocks
Release notes for pre-release version of .NET 3.0 could be read with the hopes that some of the issues raised might be fixed before shipping. However, the final release notes are worth reading, as these are known issues that were not fixed. The release notes ship with the SDK and there is some WPF issues worth calling out. I personally have been bit by the animation leaks when using Handoff.Compose. Be sure to clean your clocks!
5.1.9 Pausing and Resuming an Animation Does Not Work as Expected when
DesiredFrameRate is Set
Timeline objects with a
DesiredFrameRate value other than a null reference (Nothing in Visual Basic) do not pause and resume as expected.
InvalidCastException occurs when clicking on a ListBoxItem/ComboBoxItem/TabItem after animating
Clicking on a ListBoxItem, ComboBoxItem, or TabItem after animating the
SelectedIndex property of its ListBox, ComboBox, or TabControl container throws an
5.1.11 Performance Impacts of
When you apply an animation to a property using the Compose HandoffBehavior, any clocks objects previously associated with that property continue to consume system resources; the timing system will not remove these clocks automatically.
To avoid performance issues when you apply a large number of clocks using
HandofffBehavior.Compose, you should remove composing clocks from the animated property after they complete. There are several ways to remove a clock.
- To remove all clocks from a property, use the
BeginAnimationmethod of the animation object. Specify the property being animated as the first parameter, and a null reference (Nothing in Visual Basic) as the second. This will remove all animation clocks from the property.
- To remove a specific
AnimationClockfrom a list of clocks, use the
Controllerproperty of the
AnimationClockto retrieve a
ClockController, then call the
ClockController.Remove()method of the
ClockController. This is typically done in the
Completedevent handler for a clock. Note that only root clocks can be controlled by a
Controllerproperty of a child
Clockwill return a null reference (Nothing in Visual Basic). Note also that the
Completedevent will not be called if the effective duration of the clock is forever. In that case, the user will need to determine when to call
This is primarily an issue for animations on objects that have a long lifetime. When an object is garbage collected, its clocks will also be disconnected and garbage collected.