PauseStoryboard Class
A trigger action that pauses a Storyboard.
System.Windows.Threading::DispatcherObject
System.Windows::DependencyObject
System.Windows::TriggerAction
System.Windows.Media.Animation::ControllableStoryboardAction
System.Windows.Media.Animation::PauseStoryboard
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
The PauseStoryboard type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | BeginStoryboardName | Gets or sets the Name of the BeginStoryboard that began the Storyboard you want to interactively control. (Inherited from ControllableStoryboardAction.) |
![]() | DependencyObjectType | Gets the DependencyObjectType that wraps the CLR type of this instance. (Inherited from DependencyObject.) |
![]() | Dispatcher | Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.) |
![]() | IsSealed | Gets a value that indicates whether this instance is currently sealed (read-only). (Inherited from DependencyObject.) |
| Name | Description | |
|---|---|---|
![]() | CheckAccess | Determines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.) |
![]() | ClearValue(DependencyProperty) | Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.) |
![]() | ClearValue(DependencyPropertyKey) | Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.) |
![]() | CoerceValue | Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject. (Inherited from DependencyObject.) |
![]() | Equals | Determines whether a provided DependencyObject is equivalent to the current DependencyObject. (Inherited from DependencyObject.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Gets a hash code for this DependencyObject. (Inherited from DependencyObject.) |
![]() | GetLocalValueEnumerator | Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | GetValue | Returns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.) |
![]() | InvalidateProperty | Re-evaluates the effective value for the specified dependency property (Inherited from DependencyObject.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | OnPropertyChanged | Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. The specific dependency property that changed is reported in the event data. (Inherited from DependencyObject.) |
![]() | ReadLocalValue | Returns the local value of a dependency property, if it exists. (Inherited from DependencyObject.) |
![]() | SetCurrentValue | Sets the value of a dependency property without changing its value source. (Inherited from DependencyObject.) |
![]() | SetValue(DependencyProperty, Object) | Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.) |
![]() | SetValue(DependencyPropertyKey, Object) | Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.) |
![]() | ShouldSerializeProperty | Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property. (Inherited from DependencyObject.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | VerifyAccess | Enforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.) |
Use a PauseStoryboard with an EventTrigger or a Trigger to pause a Storyboard.
PauseStoryboard only affects a Storyboard when it is active (after the Storyboard starts).
To control a Storyboard, the PauseStoryboard must reference the Name of the BeginStoryboard that controls that Storyboard. See How to: Use Event Triggers to Control a Storyboard After It Starts for an example.
Beginning a Paused Animation
When a BeginStoryboard action is triggered after it has been paused, it appears to resume and restart. That's not what actually happens, however: the BeginStoryboard action actually replaces itself with an unpaused version. Each time a BeginStoryboard action is triggered, clock objects are created for its storyboard. These clocks are distributed to the properties they animate. So, when a BeginStoryboard is triggered again, it doesn't restart its clocks, it replaces them with new clocks.
This example shows how to control a Storyboard after it starts. To start a Storyboard by using XAML, use BeginStoryboard, which distributes the animations to the objects and properties they animate and then starts the storyboard. If you give BeginStoryboard a name by specifying its Name property, you make it a controllable storyboard. You can then interactively control the storyboard after it starts.
Use the following storyboard actions together with EventTrigger objects to control a storyboard.
PauseStoryboard: Pauses the storyboard.
ResumeStoryboard: Resumes a paused storyboard.
SetStoryboardSpeedRatio: Changes the storyboard speed.
SkipStoryboardToFill: Advances a storyboard to the end of its fill period, if it has one.
StopStoryboard: Stops the storyboard.
RemoveStoryboard: Removes the storyboard, freeing resources.
The following example uses controllable storyboard actions to interactively control a storyboard.
Note: To see an example of controlling a storyboard by using code, see How to: Control a Storyboard After It Starts.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowTitle="Controlling a Storyboard" > <StackPanel Margin="20" > <!-- This rectangle is animated. --> <Rectangle Name="myRectangle" Width="100" Height="20" Margin="12,0,0,5" Fill="#AA3333FF" HorizontalAlignment="Left" /> <!-- This StackPanel contains all the Buttons. --> <StackPanel Orientation="Horizontal" Margin="0,30,0,0"> <Button Name="BeginButton">Begin</Button> <Button Name="PauseButton">Pause</Button> <Button Name="ResumeButton">Resume</Button> <Button Name="SeekButton">Seek</Button> <Button Name="SkipToFillButton">Skip To Fill</Button> <Button Name="SetSpeedRatioButton">Triple Speed</Button> <Button Name="StopButton">Stop</Button> <StackPanel.Triggers> <!-- Begin the Storyboard --> <EventTrigger RoutedEvent="Button.Click" SourceName="BeginButton"> <BeginStoryboard Name="MyBeginStoryboard"> <Storyboard > <DoubleAnimation Storyboard.TargetName="myRectangle" Storyboard.TargetProperty="Width" Duration="0:0:5" From="100" To="500" /> </Storyboard> </BeginStoryboard> </EventTrigger> <!-- Pause the Storyboard --> <EventTrigger RoutedEvent="Button.Click" SourceName="PauseButton"> <PauseStoryboard BeginStoryboardName="MyBeginStoryboard" /> </EventTrigger> <!-- Resume the Storyboard --> <EventTrigger RoutedEvent="Button.Click" SourceName="ResumeButton"> <ResumeStoryboard BeginStoryboardName="MyBeginStoryboard" /> </EventTrigger> <!-- Seek one second into the storyboard's active period. --> <EventTrigger RoutedEvent="Button.Click" SourceName="SeekButton"> <SeekStoryboard BeginStoryboardName="MyBeginStoryboard" Offset="0:0:1" Origin="BeginTime" /> </EventTrigger> <!-- Skip to Fill --> <EventTrigger RoutedEvent="Button.Click" SourceName="SkipToFillButton"> <SkipStoryboardToFill BeginStoryboardName="MyBeginStoryboard" /> </EventTrigger> <!-- Stop the Storyboard --> <EventTrigger RoutedEvent="Button.Click" SourceName="StopButton"> <StopStoryboard BeginStoryboardName="MyBeginStoryboard" /> </EventTrigger> <!-- Triple the speed of the Storyboard --> <EventTrigger RoutedEvent="Button.Click" SourceName="SetSpeedRatioButton"> <SetStoryboardSpeedRatio SpeedRatio="3" BeginStoryboardName="MyBeginStoryboard" /> </EventTrigger> </StackPanel.Triggers> </StackPanel> </StackPanel> </Page>
For additional examples, see the Animation Example Gallery.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
