Timeline.Duration Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Windows.Media.Animation
Assembly:  PresentationCore (in PresentationCore.dll)

public Duration Duration { get; set; }

Property Value

Type: System.Windows.Duration

The timeline's simple duration: the amount of time this timeline takes to complete a single forward iteration. The default value is Automatic.

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

The behavior of a Duration structure with a value of Automatic depends on the type of timeline:




Undetermined (Timeline is abstract)




Expands to fit child timelines

<Type>Animation (Known as a "From/To/By" or "basic" animations)

1 second

<Type>AnimationUsingKeyFrames (Known as key frame animations)

Sum of all key frame KeyTime values

Identifier field


Metadata properties set to true


ParallelTimeline and Storyboard are types of TimelineGroup objects. The duration of a TimelineGroup is determined by the duration of its child timelines. For example, the Storyboard below will run for six seconds (duration of 6 seconds) because that is when its last child Timeline (DoubleAnimation) ends.


Note: code has been omitted from the following examples, which are provided for illustrative purposed only.


    <DoubleAnimation Duration="0:0:2" …/>
    <DoubleAnimation Duration="0:0:4" BeginTime="0:0:2" …/>

Examples of <Type>Animations include DoubleAnimation, PointAnimation, ColorAnimation, etc. If no Duration is specified for these types of animations, they will run for one second.


  <!-- With no Duration specified, this animation will run for 
       one second -->
  <DoubleAnimation .../>

Examples of <Type>AnimationUsingKeyFrames include DoubleAnimationUsingKeyFrames, PointAnimationUsingKeyFrames, etc. If no Duration is specified for these types of animations they will run until all key frames are finished.



    <!-- This key frame animation will end at 4.5 seconds
         Because that is when its last KeyFrame KeyTime ends. -->
    <DoubleAnimationUsingKeyFrames ...>
      <LinearDoubleKeyFrame ... KeyTime="0:0:3" />
      <DiscreteDoubleKeyFrame ... KeyTime="0:0:3.5" />
      <DiscreteDoubleKeyFrame ... KeyTime="0:0:4" />
      <DiscreteDoubleKeyFrame ... KeyTime="0:0:4.5" />

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top