Enabling and Disabling animations easily;

W

WernerG

I am trying to implement a way where I can easily enable and disable
animations via application configuration. I came up with the following
solution...

public class AnimationControl
{
.....#region const
.........public static bool enableAnimation = false;
.....#endregion

.....public static void Begin( UIElement target, DependencyProperty property,
AnimationTimeline timeline )
.....{
.........if ( enableAnimation )
.............target.BeginAnimation( property, timeline );
.........else
.........{
.............LocalValueEnumerator en = timeline.GetLocalValueEnumerator();
.............en.Reset();
.............while( en.MoveNext() )
.............{
.................if ( en.Current.Property.Name == "To" )
.....................target.SetValue( property, en.Current.Value );
.................}
.............}
.........}
.....}


This works fine. However, animations that have completed events associated
with them obviously wont work with this trick. Is there any way to manually
signal a AnimationTimeline to fire that event?

Thanks

W
 

My Computer

Top