Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-rotate-an-object-by-using-a-geometric-path-matrix-animation.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* 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
2020-09-04 09:46:28 -07:00

2.9 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Rotate an Object by Using a Geometric Path (Matrix Animation) 03/30/2017
csharp
vb
geometric paths [WPF], rotating objects by
rotating objects by geometric paths [WPF]
matrix animation [WPF]
877dc9aa-6bdc-4beb-8772-3efaec32c0f0

How to: Rotate an Object by Using a Geometric Path (Matrix Animation)

This example shows how to use a xref:System.Windows.Media.Animation.MatrixAnimationUsingPath and a xref:System.Windows.Media.MatrixTransform to rotate (pivot) an object along a geometric path defined by a xref:System.Windows.Media.PathGeometry object.

Example

The following example uses the xref:System.Windows.Media.Animation.MatrixAnimationUsingPath object to animate the xref:System.Windows.Media.MatrixTransform.Matrix%2A property of a xref:System.Windows.Media.MatrixTransform. The xref:System.Windows.Media.MatrixTransform is applied to a button and causes it to move along a curved path. Because the xref:System.Windows.Media.Animation.MatrixAnimationUsingPath.DoesRotateWithTangent%2A property is set to true, the rectangle rotates along the tangent of the path.

[!code-xamlPathAnimationGallery_snippet#MatrixAnimationUsingPathDoesRotateWithTangentWholePage]

[!code-csharpPathAnimationGallery_procedural_snip#MatrixAnimationUsingPathDoesRotateWithTangentWholePage] [!code-vbPathAnimationGallery_procedural_snip#MatrixAnimationUsingPathDoesRotateWithTangentWholePage]

For the complete sample, see Path Animation Sample.

The code version of the preceding sample used a xref:System.Windows.Media.Animation.Storyboard to animate the xref:System.Windows.Media.EllipseGeometry, even though only one animation was applied. An easier way to apply a single animation to a property in code is to use the xref:System.Windows.Media.Animation.Animatable.BeginAnimation%2A method. For an example, see Animate a Property Without Using a Storyboard.

See also