--- title: "How to: Rotate an Object by Using a Geometric Path (Matrix Animation)" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "geometric paths [WPF], rotating objects by" - "rotating objects by geometric paths [WPF]" - "matrix animation [WPF]" ms.assetid: 877dc9aa-6bdc-4beb-8772-3efaec32c0f0 --- # How to: Rotate an Object by Using a Geometric Path (Matrix Animation) This example shows how to use a and a to rotate (pivot) an object along a geometric path defined by a object. ## Example The following example uses the object to animate the property of a . The is applied to a button and causes it to move along a curved path. Because the property is set to `true`, the rectangle rotates along the tangent of the path. [!code-xaml[PathAnimationGallery_snippet#MatrixAnimationUsingPathDoesRotateWithTangentWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/PathAnimationGallery_snippet/CS/matrixanimationusingpathdoesrotatewithtangentexample.xaml#matrixanimationusingpathdoesrotatewithtangentwholepage)] [!code-csharp[PathAnimationGallery_procedural_snip#MatrixAnimationUsingPathDoesRotateWithTangentWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/PathAnimationGallery_procedural_snip/CSharp/MatrixAnimationUsingPathDoesRotateWithTangentExample.cs#matrixanimationusingpathdoesrotatewithtangentwholepage)] [!code-vb[PathAnimationGallery_procedural_snip#MatrixAnimationUsingPathDoesRotateWithTangentWholePage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PathAnimationGallery_procedural_snip/VisualBasic/MatrixAnimationUsingPathDoesRotateWithTangentExample.vb#matrixanimationusingpathdoesrotatewithtangentwholepage)] For the complete sample, see [Path Animation Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Animation/PathAnimations). The code version of the preceding sample used a to animate the , even though only one animation was applied. An easier way to apply a single animation to a property in code is to use the method. For an example, see [Animate a Property Without Using a Storyboard](how-to-animate-a-property-without-using-a-storyboard.md). ## See also - [Animation Overview](animation-overview.md) - [Path Animation How-to Topics](path-animation-how-to-topics.md) - [Path Animation Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Animation/PathAnimations)