Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 2.71 KB

how-to-repeat-an-animation.md

File metadata and controls

34 lines (25 loc) · 2.71 KB
title description ms.date helpviewer_keywords ms.assetid
How to: Repeat an Animation
Learn how to use the RepeatBehavior property of a Timeline to control the repeat behavior of an animation.
03/30/2017
RepeatBehavior property of timelines [WPF]
repeating animating [WPF]
Timelines RepeatBehavior property [WPF]
animation [WPF], repeating
e6f3b068-eeeb-47fd-8d40-8848c31f1e1e

How to: Repeat an Animation

This example shows how to use the xref:System.Windows.Media.Animation.Timeline.RepeatBehavior%2A property of a xref:System.Windows.Media.Animation.Timeline in order to control the repeat behavior of an animation.

Example

The xref:System.Windows.Media.Animation.Timeline.RepeatBehavior%2A property of a xref:System.Windows.Media.Animation.Timeline controls how many times an animation repeats its simple duration. By using xref:System.Windows.Media.Animation.Timeline.RepeatBehavior%2A, you can specify that a xref:System.Windows.Media.Animation.Timeline repeats for a certain number of times (an iteration count) or for a specified time period. In either case, the animation goes through as many beginning-to-end runs that it needs in order to fill the requested count or duration.

By default, timelines have a repeat count of 1.0, which means they play one time and do not repeat. However, if you set the xref:System.Windows.Media.Animation.Timeline.RepeatBehavior%2A property of a xref:System.Windows.Media.Animation.Timeline to xref:System.Windows.Media.Animation.RepeatBehavior.Forever%2A, the timeline repeats indefinitely.

The following example shows how to use the xref:System.Windows.Media.Animation.Timeline.RepeatBehavior%2A property to control the repeat behavior of an animation. The example animates the xref:System.Windows.FrameworkElement.Width%2A property of five rectangles with each rectangle using a different type of repeat behavior.

[!code-xamltimingbehaviors_snip#RepeatBehaviorWholePage]

For the complete sample, see Animation Timing Behavior Sample.

See also