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 |
|
|
877dc9aa-6bdc-4beb-8772-3efaec32c0f0 |
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.
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.