Friday, July 10, 2009

Minimum Code for Silverlight Animation

Let's change the height of an element.

DoubleAnimation dy = new DoubleAnimation
{
From = from * element.ActualHeight,
To = to * element.ActualHeight,
Duration = TimeSpan.FromSeconds(0.3)
};
Storyboard.SetTarget(dy, element);
Storyboard.SetTargetProperty(dy, new PropertyPath(FrameworkElement.HeightProperty));
Storyboard sb = new Storyboard();
sb.Children.Add(da);
sb.Begin();

No comments:

Post a Comment