BeginStoryboard Object

A trigger action that begins a Storyboard and distributes its animations to their targeted objects and properties.

XAML
<BeginStoryboard>
  <Storyboard .../>
</BeginStoryboard>
Scripting
To create an object using scripting, see CreateFromXAML.

Properties

Name, Storyboard

Methods

Equals, FindName, GetHost, GetValue, SetValue

Remarks

BeginStoryboard is used as a wrapper around a Storyboard that is being triggered. A BeginStoryboard can only contain one Storyboard, not a collection of them.

In addition to starting a storyboard automatically when an object loads, you can use the interactive methods of the Storyboard object to start, pause, resume, and stop an animation. For more information, see the Interactive Animations Overview.

Examples

The following example shows how to use a Storyboard and a BeginStoryboard object to make a rectangle that fades in and out of view after it is loaded.

XAML
<Canvas
  xmlns="http://schemas.microsoft.com/client/2007"
  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.0" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever" />
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </Rectangle.Triggers>
  </Rectangle>
</Canvas>

See Also

Animation Overview