Timeline.FillBehavior Property

July 28, 2014

Gets or sets a value that specifies how the animation behaves after it reaches the end of its active period.

Namespace:  System.Windows.Media.Animation
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public FillBehavior FillBehavior { get; set; }
<timeline FillBehavior="HoldEnd"/>
-or-
<timeline FillBehavior="Stop"/>

Property Value

Type: System.Windows.Media.Animation.FillBehavior
A value that specifies how the timeline behaves after it reaches the end of its active period but its parent is inside its active or fill period. The default value is HoldEnd.

Dependency property identifier field: FillBehaviorProperty

Set an animations FillBehavior property to HoldEnd when you want the animation to hold its value after it reaches the end of its active period. An animation that has reached the end of its active period that has a FillBehavior setting of HoldEnd is said to be in its fill period. When you don't want an animation to hold its value after it reaches the end of its active period, set its FillBehavior property to Stop.

A child timeline stops playing and filling when its parent timeline stops; if you want a child timeline to fill, make sure its parent timeline has a FillBehavior of HoldEnd.

The filling behavior can create the illusion that a property is unsettable at runtime if you are not careful about stopping unintended animations. Attempting to change the animated value coming from a filling animation in code will appear to have no effect until the filling animation is stopped.

The following example uses the non-default FillBehavior value of Stop. As a result, the Opacity value of the rectangle reverts to 1 after the animation ends.

<Canvas>
  <Rectangle
    x:Name="MyAnimatedRectangle"
    Width="100"
    Height="100"
    Fill="Blue">
    <Rectangle.Triggers>

      <!-- Animates the rectangle's opacity. -->
      <EventTrigger RoutedEvent="Rectangle.Loaded">
        <BeginStoryboard>
          <Storyboard>
            <DoubleAnimation
              Storyboard.TargetName="MyAnimatedRectangle"
              Storyboard.TargetProperty="Opacity"
              From="1.0" To="0" Duration="0:0:5" FillBehavior="Stop" />
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </Rectangle.Triggers>
  </Rectangle>
</Canvas>

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft