Duration Property

Gets or sets the length of time for which this timeline plays, not counting repetitions.

<object Duration="Duration" ...>
value = object.Duration
object.Duration = value

Property Value


The timeline's simple duration, which is the amount of time this timeline takes to complete a single forward iteration.

This property is read/write. The default value is null, which corresponds to the Automatic behavior.


A timeline's simple duration constitutes the time for a single forward iteration versus the total play time, which includes repetitions.

See Duration for details on the string format you use to specify a Duration value, either in script or XAML. Creating a Duration in XAML is only possible through a type conversion syntax when setting a property that takes a Duration as an attribute string. Basically, a Duration can be defined as an h:m:s string, or the special values "Automatic" or "Forever".

You can set the Duration value in script using object.Duration="stringvalue" syntax. You must use a quoted string, which then uses the same type conversion behavior as the XAML attribute syntax. You can set the value on a running animation, and the value will apply immediately. The new current state of the animation will reflect the progress of the animation that had already run prior to the change, with that same progress applied towards the new Duration. You can get the Duration value in script using value=object.Duration syntax. However, if the Duration for an animation is not explicitly set (either through scripting or XAML), then the value of object.Duration will be null. A null value for Duration has the same implied effect on an animation as does a Duration explicitly set to "Automatic".

If the AutoReverse property is set to true, the timeline plays for twice the length of time specified by its Duration.

This property applies both to specific animations and to the parent storyboard. For an animation in a storyboard, if you set a Duration other than the default "Automatic" at the storyboard level, make sure you are not unintentionally clipping the durations of child animations.

Applies To

ColorAnimation, ColorAnimationUsingKeyFrames, DoubleAnimation, DoubleAnimationUsingKeyFrames, PointAnimation, PointAnimationUsingKeyFrames, Storyboard

See Also

Animation Overview