Managing many Storyboards in a canvas
Last post 05-06-2008 6:56 AM by Sylvie. 6 replies.
Sort Posts:
04-30-2008 4:57 AM
Managing many Storyboards in a canvas

Hello Dears,

Can someone tell me what´s the proper Syntax in Silverlight 2.0 (using Visual Studio 2008) to write/declare and use more than once Storyboard in a SL Application? I will really appreciate ;). I tried the following, but I got the warning message: "Storyboard declared more than once":

<Canvas.Triggers>
<EventTrigger RoutedEvent="Canvas.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
 
<Storyboard x:Name="productPicAni">.......</Storyboard>

<Storyboard x:Name="productPicAni2">.......</Storyboard>

</BeginStoryboard>
</EventTrigger.Actions></EventTrigger></Canvas.Triggers> 

I´m Looking forward to your answers... thanks in advance!

Sylvie

Sylvie

Joined on 01-09-2008
Posts 26
04-30-2008 5:12 AM
Re: Managing many Storyboards in a canvas

I didn't try, but you can try

<Canvas.Triggers>
<EventTrigger RoutedEvent="Canvas.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
    <Storyboard x:Name="productPicAni">.......</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
    <Storyboard x:Name="productPicAni2">.......</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions></EventTrigger></Canvas.Triggers> 

 

Thierry Bouquain
Ucaya
http://www.ucaya.com

thierry.bouquain

Joined on 05-06-2007
Nantes, France
Posts 224
04-30-2008 10:16 AM
Re: Managing many Storyboards in a canvas

Thanks Thierry for your answer. I tried your code and it actually works.

Now how can I tell Silverlight which Animation must starts first and thus give a sequence (an order) of animations for my Application?

Thanks. 

Sylvie

Joined on 01-09-2008
Posts 26
04-30-2008 10:25 AM
Marked as Answer
Re: Managing many Storyboards in a canvas

You can change the BeginTime property of the storyboard you want to delay. There is no sequence object to manage the storyboard. In your sample, the storyboard are started at the same time when the Canvas is Loaded.

Thierry Bouquain
Ucaya
http://www.ucaya.com

thierry.bouquain

Joined on 05-06-2007
Nantes, France
Posts 224
05-06-2008 4:56 AM
Re: Managing many Storyboards in a canvas

Hello Guys,

It´s me again...
Things just don´t work the way I want them to Hmm . I set the Begintime of the second Storyboard I wanted to delay, but so the first don´t work anymore, the screen remains blank until the Begintime of the second. I also notice that it seems as though I can´t animate the same Targetproperty of a same Targetname twice in respectively two Storyboard. The point is, let´s say I want an ellipse when the canvas is loaded (first Storyboard) to get from top to the bottom and stay there. And then later at a certain time (The second Storyboard), I want the same ellipse to get from the bottom to the top of the canvas. I use for this the Canvas.Top property. What I get is just the ellipse moving on the top when the begintime of the second Storyboard arrives and nothing when the canvas is loaded. How can I manage to get the first Storyboard working too? I am kind of desperate.

<BeginStoryboard>
<Storyboard x:Name="productPicAni">
<DoubleAnimation BeginTime="00:00:04" From="200" To="800" Duration="00:00:05" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Canvas.Top)"/>
</Storyboard>
</BeginStoryboard>

<BeginStoryboard>
<Storyboard x:Name="productPicAni2" BeginTime="00:00:25">
<DoubleAnimation BeginTime="00:00:00" From="800" To="200" Duration="00:00:05" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Canvas.Top)"/>
</Storyboard>
</BeginStoryboard>

Looking forward to your many answers...

Sylvie

Sylvie

Joined on 01-09-2008
Posts 26
05-06-2008 5:29 AM
Marked as Answer
Re: Managing many Storyboards in a canvas

You can't animate a property in two storyboards at the same time.

You should use a DoubleAnimationWithKeyFrame

<BeginStoryboard>
<Storyboard x:Name="productPicAni">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Canvas.Top)">
<DoubleKeyFrame KeyTime="00:00:00" Value="200"/>
<DoubleKeyFrame KeyTime="00:00:05" Value="800"/>
<DoubleKeyFrame KeyTime="00:00:25" Value="800"/>
<DoubleKeyFrame KeyTime="00:00:30" Value="200"/>

</DoubleAnimationUsingKeyFrames>
</
Storyboard>
</BeginStoryboard>

Thierry Bouquain
Ucaya
http://www.ucaya.com

thierry.bouquain

Joined on 05-06-2007
Nantes, France
Posts 224
05-06-2008 6:56 AM
Re: Managing many Storyboards in a canvas

Dear Thierry,

I wrote your code, and I got this error message: Type DoubleKeyFrame is not usable as an object element because it is not public and does not define a public parameterless constructor or a type converter. So, I wrote SplineDoubleKeyFrame instead and... it works!!! You´re great!

You saved my day, thanks thanks a lot!!! I would have keep on working with two Storyboards in vain.

Have a nice day you all, bye,

Sylvie

Sylvie

Joined on 01-09-2008
Posts 26