views:

129

answers:

2

After running WPF animations on dependency properties in code behind, the dependency properties can no longer be set using SetValue. They can only be changed through animations.

I want to change a dependency property, some times through short animations, sometimes immediately in code.

So how can I remove the animation from a dependency property after the animation has reached its end?

+3  A: 

Set the animation's FillBehaviour to Stop. Then call BeginAnimation. Then set the property value to the end value of the animation.

Now, after the animation is finished, the property will work as a normal property again.

Guge
+2  A: 

After the animation ends (or when you want it to stop):

myButton.Width = myButton.Width; // set current value to the end value of the animation
myButton.ApplyAnimationClock(Button.WidthProperty, null); // remove animation

For a library that makes it real easy take a look at http://code.google.com/p/wpf-animation/

Nir
Thanks, this is the solution for a repeating animation. My own solution is only good for non-repeating animations.
Guge
Thanks, that animation library solve a few annoyances for me.
Ashley Davis