Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to autoplay storyboard animation on page load using Expression Blend

I've got a storyboard that should play when a page loads. Is there any way to do that directly from Expression Blend? I'd rather not do it through code or xaml.

What about doing the same for button clicks or other events?

Thanks

like image 731
Zain Rizvi Avatar asked May 12 '11 08:05

Zain Rizvi


2 Answers

You can drag the ControlStoryboardAction behaviour (Assets->Behaviors) over to the Page, and set the EventName to be PageLoaded, and ControlStoryboardOption to Play, and Storyboard to your storyboard.

like image 58
Damian Avatar answered Sep 30 '22 09:09

Damian


If you decide to do this via code then all you need to do is just to call Begin() of the StoryBoard. Like for example:

<Storyboard x:Name="fadeIn">
        <DoubleAnimation Storyboard.TargetName="img"
                         Storyboard.TargetProperty="Opacity" From="0.0"
                         To="1.0" Duration="0:0:1" />
    </Storyboard>


private void btnFadeIn_Click(object sender, RoutedEventArgs e)
{
    this.fadeIn.Begin();
}
like image 45
Boryana Miloshevska Avatar answered Sep 30 '22 08:09

Boryana Miloshevska