I would like to create animations where Duration is not set, but instead it is calculated based on an absolute speed setting. E.g. I want the animation to happen at 100 pixels/second and the duration is calculated automatically based on To and From values. If the path is 350 pixels, the animation will take 3.5 seconds to finish.
Duration.Automatic
is NOT for this. Also Animation.SpeedRatio
is a different thing.
I can of course calculate the duration from the path length, but I will have many objects moving on the screen, each created and removed procedural way and personally find it clumsy to bother with this.
What is a nice solution? Is there any built-in behaviour for this in Silverlight 4 or later?
Imaginary code:
DoubleAnimation ani = new DoubleAnimation();
ani.From = 0;
ani.To = 200;
ani.AbsoluteSpeed = "300 pixels / sec";
storyBoard1.Begin(); // now my animation will take 0.66 sec
ani.Duration = new Duration(TimeSpan.FromSeconds(200/300))
? Please add more detail regarding your objection to this approach.