Wednesday, June 9, 2010

Color Animation in silverlight

1.Creating storyboard object.

private Storyboard str_board= new Storyboard();

2.Creating coloranimation object.
On the next line, declare a new ColorAnimation object called BlueColor:

private ColorAnimation BlueColor = new ColorAnimation();

3.Setting Targetname and TargetProperty to the storyboard.


BlueColor.SetValue(Storyboard.TargetNameProperty, "MyEllipse");
BlueColor.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(Shape.Fill).(SolidColorBrush.Color)"));

4.Change to new color.

Color ToColor = Color.FromArgb(255, 13, 8, 116);
BlueColor.To = ToColor;


5.The animation can now be added to the storyboard, and the storyboard added to the LayoutRoot element:

TurnsBlue.Children.Add(BlueColor);
LayoutRoot.Resources.Add("TurnsBlue",TurnsBlue);

Aravindbenator@gmail.com

No comments:

Post a Comment