This documentation is archived and is not being maintained.

PointAnimationUsingPath.PathGeometry Property

Specifies the geometry used to generate this animation's output values.

Namespace:  System.Windows.Media.Animation
Assembly:  PresentationCore (in PresentationCore.dll)

public PathGeometry PathGeometry { get; set; }
    <PathGeometry .../>

Property Value

Type: System.Windows.Media.PathGeometry
The path used to generate this animation's output values. The default value is null.

Identifier field


Metadata properties set to true


For examples of creating a path using markup or code, see PathGeometry.

This example shows how to use a PointAnimationUsingPath object to animate a Point along a curved path.

The following example moves an EllipseGeometry along a path defined by a PathGeometry. The ellipse geometry's Center property, which takes a Point value, specifies its position; to move the ellipse geometry, you animate its Center property. The example uses a PointAnimationUsingPath to animate the EllipseGeometry object's Center property.

  <Canvas Width="400" Height="400">

    <Path Fill="Blue" Margin="15,15,15,15">

        <!-- The EllipseGemetry specifies the shape and position of the Ellipse. The
        Center property is animated, causing the Ellipse to animate across the screen-->
        <EllipseGeometry x:Name="MyAnimatedEllipseGeometry"
          Center="10,100" RadiusX="15" RadiusY="15" />
        <EventTrigger RoutedEvent="Path.Loaded">
          <BeginStoryboard Name="MyBeginStoryboard">

              <!-- Animates the ellipse along the path. -->
                RepeatBehavior="Forever" >
                    Figures="M 10,100 C 35,0 135,0 160,100 180,190 285,200 310,100"
                    PresentationOptions:Freeze="True" />

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SDKSample

    public class PointAnimationUsingPathExample : Page

        public PointAnimationUsingPathExample()

            // Create a NameScope for the page so that
            // we can use Storyboards.
            NameScope.SetNameScope(this, new NameScope());

            // Create the EllipseGeometry to animate.
            EllipseGeometry animatedEllipseGeometry =
                new EllipseGeometry(new Point(10, 100), 15, 15);

            // Register the EllipseGeometry's name with
            // the page so that it can be targeted by a
            // storyboard.
            this.RegisterName("AnimatedEllipseGeometry", animatedEllipseGeometry);

            // Create a Path element to display the geometry.
            Path ellipsePath = new Path();
            ellipsePath.Data = animatedEllipseGeometry;
            ellipsePath.Fill = Brushes.Blue;
            ellipsePath.Margin = new Thickness(15);

            // Create a Canvas to contain ellipsePath
            // and add it to the page.
            Canvas mainPanel = new Canvas();
            mainPanel.Width = 400;
            mainPanel.Height = 400;
            this.Content = mainPanel;

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();
            pFigure.StartPoint = new Point(10, 100);
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pBezierSegment.Points.Add(new Point(35, 0));
            pBezierSegment.Points.Add(new Point(135, 0));
            pBezierSegment.Points.Add(new Point(160, 100));
            pBezierSegment.Points.Add(new Point(180, 190));
            pBezierSegment.Points.Add(new Point(285, 200));
            pBezierSegment.Points.Add(new Point(310, 100));

            // Freeze the PathGeometry for performance benefits.

            // Create a PointAnimationgUsingPath to move
            // the EllipseGeometry along the animation path.
            PointAnimationUsingPath centerPointAnimation = 
                new PointAnimationUsingPath();
            centerPointAnimation.PathGeometry = animationPath;
            centerPointAnimation.Duration = TimeSpan.FromSeconds(5);
            centerPointAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Set the animation to target the Center property
            // of the EllipseGeometry named "AnimatedEllipseGeometry".
            Storyboard.SetTargetName(centerPointAnimation, "AnimatedEllipseGeometry");
                new PropertyPath(EllipseGeometry.CenterProperty));

            // Create a Storyboard to contain and apply the animation.
            Storyboard pathAnimationStoryboard = new Storyboard();
            pathAnimationStoryboard.RepeatBehavior = RepeatBehavior.Forever;
            pathAnimationStoryboard.AutoReverse = true;

            // Start the Storyboard when ellipsePath is loaded.
            ellipsePath.Loaded += delegate(object sender, RoutedEventArgs e)
                // Start the storyboard.



For the complete sample, see Path Animation Sample.

The code version of the preceding sample used a Storyboard to animate the EllipseGeometry, even though only one animation was applied. A Storyboard is often the easiest way to apply multiple animations because these animations can be controlled by the same Storyboard. However, an easier way to apply a single animation to a property when using code is to use the BeginAnimation method. For an example, see How to: Animate a Property Without Using a Storyboard.

More Code

How to: Rotate an Object by Using a Geometric PathThis example shows how to rotate (pivot) an object along a geometric path that is defined by a PathGeometry object.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.