共用方式為


Timeline.FillBehavior Property

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

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)

Syntax

'Declaration
Public Property FillBehavior As FillBehavior
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.

Remarks

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.

Examples

The following example uses the nondefault 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>

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.