* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.5 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Animate an Object Along a Path (Double Animation) | 03/30/2017 |
|
|
5a3c4a99-f303-42ad-a52a-e4794bb1798e |
How to: Animate an Object Along a Path (Double Animation)
This example shows how to use the xref:System.Windows.Media.Animation.DoubleAnimationUsingPath class to move an object along a path defined by a xref:System.Windows.Media.PathGeometry.
Example
The following example uses two xref:System.Windows.Media.Animation.DoubleAnimationUsingPath objects to move a rectangle along a geometric path:
-
The first xref:System.Windows.Media.Animation.DoubleAnimationUsingPath animates the xref:System.Windows.Media.TranslateTransform.X%2A of the xref:System.Windows.Media.TranslateTransform applied to the rectangle. It makes the rectangle move horizontally along the path.
-
The second xref:System.Windows.Media.Animation.DoubleAnimationUsingPath animates the xref:System.Windows.Media.TranslateTransform.Y%2A of the xref:System.Windows.Media.TranslateTransform applied to the rectangle. It makes the rectangle move vertically along the path.
[!code-xamlPathAnimationGallery_snippet#DoubleAnimationUsingPathWholePage]
[!code-csharpPathAnimationGallery_procedural_snip#DoubleAnimationUsingPathWholePage] [!code-vbPathAnimationGallery_procedural_snip#DoubleAnimationUsingPathWholePage]
For the complete sample, see Path Animation Sample.
Another way to move an object using a geometric path is to use a xref:System.Windows.Media.Animation.MatrixAnimationUsingPath object. For an example, see Animate an Object Along a Path (Matrix Animation).