Controls animations with a timeline, and provides object and property targeting information for its child animations.
Inheritance
- Object
- DependencyObject
- Timeline
- Storyboard
Syntax
<Storyboard ...> oneOrMoreChildTimelines </Storyboard>
XAML Values
- oneOrMoreChildTimelines
-
One or more object elements for classes that derive from Timeline. This can be either another Storyboard or any of a number of animation types.
Attributes
- ActivatableAttribute(NTDDI_WIN8)
- ContentPropertyAttribute(Name=Children)
- MarshalingBehaviorAttribute(Agile)
- StaticAttribute(Windows.UI.Xaml.Media.Animation.IStoryboardStatics, NTDDI_WIN8)
- ThreadingAttribute(Both)
- VersionAttribute(NTDDI_WIN8)
- WebHostHiddenAttribute()
Members
The Storyboard class has these types of members:
Constructors
The Storyboard class has these constructors.
| Constructor | Description |
|---|---|
| Storyboard | Initializes a new instance of the Storyboard class. |
Events
The Storyboard class has these events.
| Event | Description |
|---|---|
| Completed | Occurs when the Storyboard object has completed playing. (Inherited from Timeline) |
Methods
The Storyboard class has these methods. It also inherits methods from the Object class.
| Method | Description |
|---|---|
| Begin | Initiates the set of animations associated with the storyboard. |
| ClearValue | Clears the local value of a dependency property. (Inherited from DependencyObject) |
| GetAnimationBaseValue | Returns any base value established for a dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject) |
| GetCurrentState | Gets the clock state of the Storyboard. |
| GetCurrentTime | Gets the current animation clock time of the Storyboard. |
| GetTargetName | Gets the value of the Storyboard.TargetName XAML attached property from a target element. |
| GetTargetProperty | Gets the value of the Storyboard.TargetProperty XAML attached property from a target element. |
| GetValue | Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject) |
| Pause | Pauses the animation clock associated with the storyboard. |
| ReadLocalValue | Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject) |
| Resume | Resumes the animation clock, or run-time state, associated with the storyboard. |
| Seek | Moves the storyboard to the specified animation position. The storyboard performs the requested seek when the next clock tick occurs. |
| SeekAlignedToLastTick | Moves the storyboard to the specified animation position immediately (synchronously). |
| SetTarget | Causes the specified Timeline to target the specified object. |
| SetTargetName | Sets the value of the Storyboard.TargetName XAML attached property for a target element. |
| SetTargetProperty | Sets the value of the Storyboard.TargetProperty XAML attached property for a target element. |
| SetValue | Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject) |
| SkipToFill | Advances the current time of the storyboard's clock to the end of its active period. |
| Stop | Stops the storyboard. |
Attached Properties
The Storyboard class has these attached properties.
| Access type | Description | |
|---|---|---|
| Read/write | Gets or sets the name of the object to animate. | |
| Read/write | Gets or sets the property that should be animated. |
Properties
The Storyboard class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read/write | Gets or sets a value that indicates whether the timeline plays in reverse after it completes a forward iteration. (Inherited from Timeline) | |
| Read/write | Gets or sets the time at which this Timeline should begin. (Inherited from Timeline) | |
| Read-only | Gets the collection of child Timeline objects. | |
| Read-only | Gets the CoreDispatcher that this object is associated with. (Inherited from DependencyObject) | |
| Read/write | Gets or sets the length of time for which this timeline plays, not counting repetitions. (Inherited from Timeline) | |
| Read/write | Gets or sets a value that specifies how the animation behaves after it reaches the end of its active period. (Inherited from Timeline) | |
| Read/write | Gets or sets the repeating behavior of this timeline. (Inherited from Timeline) | |
| Read/write | Gets or sets the rate, relative to its parent, at which time progresses for this Timeline. (Inherited from Timeline) | |
| Read-only | Identifies the Storyboard.TargetName XAML attached property. | |
| Read-only | Identifies the Storyboard.TargetProperty XAML attached property. |
Remarks
Storyboard is an important class in the concept of storyboarded animations. For more info on the concept, see Storyboarded animations.
Storyboard is used for these properties:
These properties aren't the only place where a Storyboard is defined. The typical way that a Storyboard is used for a storyboarded animation is that the Storyboard is defined in a Resources collection (either Application.Resources or FrameworkElement.Resources, or possibly as a resource in a file such as StandardStyles.xaml). If used in this way, you should always assign an x:Name attribute value to your Storyboard. You can then reference the name as a programming variable later in code-behind. You'll need this reference to actually run the animations that the Storyboard contains, by calling the Begin method on that Storyboard instance. Storyboard also has other control methods.
Storyboard inherits several properties from Timeline. These properties can be applied either to a Storyboard or to one of the animations within it (in the Children collection). There are pros and cons to setting Timeline properties on the main Storyboard instead of on each animation. For more info, see Storyboarded animations.
You also need a Storyboard in order to control the personality animations that you add to controls or UI, if you are using one of the theme animations. Theme animations don't have an innate trigger point, so you need to group theme animations in a Storyboard as the Children, and call Begin in your app's logic when you handle trigger events for each type of theme animation. For more info, see Quickstart: Animating your UI.
Storyboard XAML attached properties
Storyboard is the host service class for several XAML attached properties. Theses enable child animations under control by the Storyboard to each target separate target elements and target properties, while still following the same controlling timeline and triggering mechanism as the parent.
The XAML attached properties that are supported by Storyboard are:
Storyboard.TargetName is used to reference another element by its name. The element being referenced is the element/object where the animation should apply. This mechanism is part of the basic design of the animation system: it enables animation resources to be declared separately from UI declaration resources, and makes animation repurposing possible. For the value of Storyboard.TargetName on a particular animation, you specify the target element's Name or x:Name attribute value, which is a string. That named element should already exist in some other area of XAML markup.
Storyboard.TargetProperty targets a particular property of the element as named by Storyboard.TargetName. The value you provide for Storyboard.TargetProperty involves a concept known as a property path. For more information on how to specify a property path for an animation, see Remarks in SetTargetProperty or Storyboard.TargetProperty, or the PropertyPath syntax topic.
In order to support XAML processor access to the attached properties, and also to expose equivalent get and set operations to code, each XAML attached property has a pair of Get and Set accessor methods. For example, the GetTargetName and SetTargetName methods support and provide the equivalent code-only support for Storyboard.TargetName. Alternatively, you can use the dependency property system to get or set the value of the attached property. Call GetValue or SetValue, passing the arguments of the dependency property identifier to set, and a reference to the target object on which to get or set the value.
Examples
The following example shows how to use the Begin, Stop, Pause, and Resume methods to control the playback of a storyboard (animation). A set of buttons allow the user to call these methods.
<StackPanel x:Name="LayoutRoot" > <StackPanel.Resources> <Storyboard x:Name="myStoryboard"> <DoubleAnimation From="1" To="6" Duration="00:00:6" Storyboard.TargetName="rectScaleTransform" Storyboard.TargetProperty="ScaleY"> <DoubleAnimation.EasingFunction> <BounceEase Bounces="2" EasingMode="EaseOut" Bounciness="2" /> </DoubleAnimation.EasingFunction> </DoubleAnimation> </Storyboard> </StackPanel.Resources> <!-- Button that begins animation. --> <Button Click="Animation_Begin" Margin="2" Content="Begin" /> <!-- Button that pauses Animation. --> <Button Click="Animation_Pause" Margin="2" Content="Pause" /> <!-- Button that resumes Animation. --> <Button Click="Animation_Resume" Margin="2" Content="Resume" /> <!-- Button that stops Animation. Stopping the animation returns the ellipse to its original location. --> <Button Click="Animation_Stop" Margin="2" Content="Stop" /> <Rectangle Fill="Blue" Width="200" Height="30"> <Rectangle.RenderTransform> <ScaleTransform x:Name="rectScaleTransform" /> </Rectangle.RenderTransform> </Rectangle> </StackPanel>
The following example shows how to create a Storyboard using code.
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
See also
- Timeline
- Quickstart: Animating your UI
- Key-frame animations and easing function animations
- Property path syntax
- Storyboarded animations
- Storyboarded animations for visual states
- Attached properties overview
- PropertyPath syntax
Build date: 12/4/2012