An animation updates the value of a property over a period of time. An animation effect can be subtle, such as moving a Shape object a few pixels left or right, or dramatic, such as enlarging an object to 200 times its original size while spinning it and changing its color. To create an animation, you associate an animation with an object's property value.
The PointAnimation class creates a transition between two target values. To set the target values, use the object's From, To, and By properties. The following table summarizes how you can use the From, To, and By properties together or separately to determine an animation's target values.
The animation progresses from the value of the From property to the base value of the property being animated.
From and To
The animation progresses from the value of the From property to the value of the To property.
From and By
The animation progresses from the value of the From property to the value specified by the sum of the From and By properties.
The animation progresses from the animated property's base value or a previous animation's output value to the value of the To property.
The animation progresses from the base value of the property being animated or a previous animation's output value to the sum of that value and the value of the By property.
If you set both the To and By properties, the To property takes precedence and the By property is ignored.
To use other interpolation methods or to animate between more than two target values, use the PointAnimationUsingKeyFrames object.
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300"> <Path Fill="Blue"> <Path.Data> <!-- Describes an ellipse. --> <EllipseGeometry x:Name="MyAnimatedEllipseGeometry" Center="200,100" RadiusX="15" RadiusY="15" /> </Path.Data> <Path.Triggers> <EventTrigger RoutedEvent="Path.Loaded"> <BeginStoryboard> <Storyboard> <!-- Animate the center point of the ellipse from 100,300 to 400,100 over 5 seconds. --> <PointAnimation Storyboard.TargetProperty="Center" Storyboard.TargetName="MyAnimatedEllipseGeometry" Duration="0:0:5" From="100,300" To="400,100" RepeatBehavior="Forever" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Path.Triggers> </Path> </Canvas>