--- title: "How to: Animate an Object Along a Path (Matrix Animation with Offset Accumulation)" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "offset accumulation [WPF]" - "animation [WPF], objects along paths (matrix animation with offset accumulation)" - "matrix animation with offset accumulation [WPF]" ms.assetid: 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 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 object to animate the property of a applied to a button. As a result, a button moves along a curved path. In addition, the example sets the 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-xaml[PathAnimationGallery_snippet#MatrixAnimationUsingPathOffsetCumulativeWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/PathAnimationGallery_snippet/CS/matrixanimationusingpathexampleoffsetcumulative.xaml#matrixanimationusingpathoffsetcumulativewholepage)] [!code-csharp[PathAnimationGallery_procedural_snip#MatrixAnimationUsingPathOffsetCumulativeWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/PathAnimationGallery_procedural_snip/CSharp/MatrixAnimationUsingPathExampleOffsetCumulative.cs#matrixanimationusingpathoffsetcumulativewholepage)] [!code-vb[PathAnimationGallery_procedural_snip#MatrixAnimationUsingPathOffsetCumulativeWholePage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/PathAnimationGallery_procedural_snip/VisualBasic/MatrixAnimationUsingPathExampleOffsetCumulative.vb#matrixanimationusingpathoffsetcumulativewholepage)] Note that, although the 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 and properties to `true`. For the complete sample, see [Path Animation Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Animation/PathAnimations). For an example showing how to animate a value along a path without offset accumulation, see [Animate an Object Along a Path (Matrix Animation)](how-to-animate-an-object-along-a-path-matrix-animation.md). ## See also - [Animation Overview](animation-overview.md) - [Path Animation How-to Topics](path-animation-how-to-topics.md)