Gets or sets a value that specifies how the animation behaves after it reaches the end of its active period.
Type: FillBehavior Enumeration
One of the enumeration values 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.
This property is read/write. The default value is HoldEnd.
The FillBehavior property specifies how a timeline behaves when it ends. By default, a timeline starts filling when it ends. An animation that is filling holds its final output value.
The filling behavior can create the illusion that a property is unsettable at run time 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 nondefault FillBehavior value of Stop. As a result, the Opacity value of the rectangle reverts to 1 after the animation ends.
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <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>