Skip to content

ControlStoryboardAction

Jon W Chu edited this page Nov 16, 2015 · 1 revision

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

Using this Behaviors enables the triggering and controlling of a specified Storyboard using the ControlStoryboardOption property.

ControlStoryboardOption Enumeration

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

Sample Code

XAML

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

<Button x:Name="button">
    <Interactivity:Interaction.Behaviors>
        <Interactions:EventTriggerBehavior EventName="Click">
            <Media:ControlStoryboardAction Storyboard="{StaticResource StoryboardSample}" ControlStoryboardOption="TogglePlayPause"/>
        </Interactions:EventTriggerBehavior>
    </Interactivity:Interaction.Behaviors>
</Button>