Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/animate-an-object-along-a-path-matrix-animation-with-offset.md
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

3.2 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 (Matrix Animation with Offset Accumulation) 03/30/2017
csharp
vb
offset accumulation [WPF]
animation [WPF], objects along paths (matrix animation with offset accumulation)
matrix animation with offset accumulation [WPF]
1bca90ef-9832-4128-8ed6-62908e7ec146

How to: Animate an Object Along a Path (Matrix Animation with Offset Accumulation)

This example shows how to use the xref:System.Windows.Media.Animation.MatrixAnimationUsingPath class to animate an object along a path and have that animation accumulate its offset values as it repeats.

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 applied to a button. As a result, a button moves along a curved path.

In addition, the example sets the xref:System.Windows.Media.Animation.MatrixAnimationUsingPath.IsOffsetCumulative%2A property to true, which causes the offset of the animated matrix to accumulate as the animation repeats. Because the offset accumulates, the button moves farther across the screen when the animation repeats, rather than resetting to the starting position.

[!code-xamlPathAnimationGallery_snippet#MatrixAnimationUsingPathOffsetCumulativeWholePage]

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

Note that, although the xref:System.Windows.Media.Animation.MatrixAnimationUsingPath.IsOffsetCumulative%2A property causes offset values to accumulate over repetitions, it doesn't cause rotation values to accumulate. To make rotation values accumulate, set the animation's xref:System.Windows.Media.Animation.MatrixAnimationUsingPath.DoesRotateWithTangent%2A and xref:System.Windows.Media.Animation.MatrixAnimationUsingPath.IsAngleCumulative%2A properties to true.

For the complete sample, see Path Animation Sample. For an example showing how to animate a xref:System.Windows.Media.Matrix value along a path without offset accumulation, see Animate an Object Along a Path (Matrix Animation).

See also