Duration (Timeline)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Type: Duration

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.

Managed Equivalent

Duration

Remarks

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

For more information about the string format you use to specify a Duration value, either in script or in XAML, see the Duration reference topic. Creating a Duration in XAML is possible only 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 by using the special values Automatic or Forever.

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

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

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