--- title: "How to: Set a Duration for an Animation" ms.date: "03/30/2017" helpviewer_keywords: - "animation [WPF], duration" - "Timelines [WPF], description" - "duration of animations [WPF]" ms.assetid: 155034ef-7d00-4416-a73c-b1713992d2eb --- # How to: Set a Duration for an Animation A represents a segment of time and the length of that segment is determined by the timeline's . When a reaches the end of its duration, it stops playing. If the has child timelines, they stop playing as well. In the case of an animation, the specifies how long the animation takes to transition from its starting value to its ending value. You can specify a with a specific, finite time or the special values or . An animation's duration must always be a time value, because an animation must always have a defined, finite length—otherwise, the animation would not know how to transition between its target values. Container timelines ( objects), such as and , have a default duration of , which means they automatically end when their last child stops playing. In the following example, the width, height and fill color of a is animated. Durations are set on animation and container timelines resulting in animation effects including controlling the perceived speed of an animation and overriding the duration of child timelines with the duration of a container timeline. ## Example [!code-xaml[timingbehaviors_snip#DurationExampleWholePage](~/samples/snippets/csharp/VS_Snippets_Wpf/timingbehaviors_snip/CSharp/DurationExample.xaml#durationexamplewholepage)] ## See also - - [Animation Overview](animation-overview.md)