Search This Blog

Mind freaker Stuff

Please Visit my new blog http://www.mindfreakerstuff.com for new articles related to web and mobile designing.

Friday, April 1, 2011

Silverlight simple animation with Easing C#

Animated Rectangle width with Easing


           //Easing effect for Object
            var ease = new PowerEase { EasingMode = EasingMode.EaseOut };

            // Create Storyboard for animation
            Storyboard storyboard = new Storyboard(); 
            DoubleAnimation doubleAnimatoin = new DoubleAnimation();
            doubleAnimatoin.EasingFunction = ease;

           // "objectName " is name of object to be animated.

            doubleAnimatoin.From = objectName.Width;
            doubleAnimatoin.To = 100; 
            doubleAnimatoin.Duration = new Duration(TimeSpan.FromMilliseconds(400));
         
            Storyboard.SetTarget(doubleAnimatoin, objectName);
            Storyboard.SetTargetProperty(doubleAnimatoin, new PropertyPath("(objectName.Width)")); 
  
            storyboard.Children.Add(doubleAnimatoin); 
            storyboard.Begin();


- Amey Raut

No comments:

Post a Comment