I'm running into a really weird issue with Silverlight 3. I've defined an extension method to create a storyboard around a given DoubleAnimation and play that animation. I know the default duration for storyboards in Silverlight is 1s, but I would like to change that for my animations. However, when I set a different duration, instead of altering the animation to move from start to finish in the allotted time, the animation will just play for the duration I specified and then stop. For example, if I'm moving something from 0,0 to 0,10 and set the duration to .3s, the item will only move to 0.3. I can't imagine this is by design. Any ideas what is going on here?
Here's the code I'm using. ConfigureStoryboard is where the storyboard is created around the animation. I've removed some code regarding the easing function to make it more readable.
public static void BeginAnimation(
this Transform transform,
DependencyProperty property,
DoubleAnimation animation,
EasingFunction function
)
{
var storyboard = new Storyboard();
ConfigureStoryboard(animation, storyboard, function);
Storyboard.SetTarget(storyboard, transform);
Storyboard.SetTargetProperty(
storyboard,
new PropertyPath(property));
storyboard.Begin();
}
private static void ConfigureStoryboard(DoubleAnimation animation, Storyboard storyboard, EasingFunction function)
{
DoubleAnimation myAnimation = new DoubleAnimation();
storyboard.Duration = animation.Duration;
myAnimation.From = animation.From;
myAnimation.To = animation.To;
storyboard.Children.Add(myAnimation);
}