Friday, July 10, 2009

Minimum Code for Silverlight Animation

Let's change the height of an element.
  1. DoubleAnimation dy = new DoubleAnimation  
  2. {  
  3.   From = from * element.ActualHeight,  
  4.   To = to * element.ActualHeight,  
  5.   Duration = TimeSpan.FromSeconds(0.3)  
  6. };  
  7. Storyboard.SetTarget(dy, element);  
  8. Storyboard.SetTargetProperty(dy, new PropertyPath(FrameworkElement.HeightProperty));  
  9. Storyboard sb = new Storyboard();  
  10. sb.Children.Add(da);  
  11. sb.Begin();  

No comments:

Post a Comment