Tutorial :Why can't I modify an object after animating it?



Question:

After executing this code...

DoubleAnimation a = new DoubleAnimation(newWidth, new Duration(...));  ThicknessAnimation b = new ThicknessAnimation(new Thickness(...), new Duration(...));  border.BeginAnimation(Border.MarginProperty, b);  border.BeginAnimation(Border.WidthProperty, a);  

...this code no longer works (Margin does not change after assigning a new value):

// doesn't have any effect  border.Margin = new Thickness(...);  

What's going on?? Thanks!


Solution:1

From Dependency Properties Overview:

Dependency properties can be animated. When an animation is applied and is running, the animated value operates at a higher precedence than any value (such as a local value) that the property otherwise has.

You'll need to set the animation's FillBehavior to Stop for the local value to take precedence.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »