Button myButton = new Button(); DoubleAnimation animation = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(2)); myButton.ApplyAnimation(Button.OpacityProperty, animation);
Rectangle myRectangle = new Rectangle(); DoubleAnimation animation = new DoubleAnimation(100, 200, TimeSpan.FromSeconds(2)); myRectangle.ApplyAnimation(Rectangle.WidthProperty, animation);In this example, we create a new rectangle and a DoubleAnimation that animates the width property of the rectangle from 100 to 200 over a period of 2 seconds using the ApplyAnimation method. Package library: PresentationFramework