Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 3.07 KB

how-to-rotate-an-object-by-using-a-geometric-path-matrix-animation.md

File metadata and controls

35 lines (26 loc) · 3.07 KB
title description ms.date dev_langs helpviewer_keywords ms.assetid
How to: Rotate an Object by Using a Geometric Path (Matrix Animation)
Learn how to use a MatrixAnimationUsingPath and a MatrixTransform to rotate an object along a geometric path defined by a PathGeometry object.
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