Skip to content

ControlStoryboardAction

branh edited this page Dec 4, 2018 · 1 revision

ControlStoryboardAction represents an action that will change the state of the specified Storyboard when executed.

Using this behavior enables the triggering and controlling of a specified Storyboard using the ControlStoryboard property

ControlStoryboardOption enumeration

Member Name Description
Play Starts the storyboard.
Stop Stops the storyboard.
TogglePlayPause Toggles the storyboard between playing and pausing.
Pause Pauses the storyboard.
Resume Resumes the storyboard after being paused.
SkipToFill Advances the storyboard's current time to the end of its active period.

Sample Code

Xaml

<UserControl.Resources>
  <Storyboard x:Key="StoryboardSample" AutoReverse="True" RepeatBehavior="Forever">
    <DoubleAnimation Duration="0:0:2.2" To="0.35"
      Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"
      Storyboard.TargetName="StoryboardRectangle" d:IsOptimized="True"/>
    <DoubleAnimation Duration="0:0:2.2" To="0.35"
      Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)"
      Storyboard.TargetName="StoryboardRectangle" d:IsOptimized="True"/>
  </Storyboard>
 </UserControl.Resources>

<Rectangle x:Name="StoryboardRectangle" />
<Button x:Name="button">
  <Behaviors:Interaction.Triggers>
    <Behaviors:EventTrigger EventName="Click">
      <Behaviors:ControlStoryboardAction Storyboard="{StaticResource StoryboardSample}" ControlStoryboardOption="TogglePlayPause"/>
    </Behaviors:EventTrigger>
  </Behaviors:Interaction.Triggers>
</Button>