Click here to Skip to main content
14,970,700 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have a silverlight control and a whole load of storyboards. Most of them run on mouse enter so i'm wondering if there's a way i can prevent other storyboards from running when a storyboard is already being run.
I have:

C#
cWp1.Begin();
Canvas.SetZIndex(c1, 99);
this.b1.Visibility = Visibility.Visible; <!--Reverse storyboard button -->
<!--Want to prevent these storyboards from starting-->
cWp2.Stop();
cWp1.Stop();


My aim is to have three canvases side by side and have them grow and shift location on mouse enter. I got that working but if i accidentally mouse over the other controls, other storyboards start and gets everything messed up.
Posted
Updated 20-Aug-11 1:32am
v2

Silverlight supports multiple story boards running in parallel.
The simplest way to do this would be to do this by keeping track of all the storyboards - say in a collection.
Whenever you want to run a particular one, loop through this collection and stop all others.
   
Comments
Deaths_eclipsE 21-Aug-11 8:47am
   
Do you mind showing me how this can be achieved? Because i don't know how to prevent others from starting when one is running.
Check your storyboard very well, it is possible you are starting the three storyboard at the same time. You have to set the OnMouseOver for each canvas so that each storyboard will start as appropriate. Now if you hover your mouse on canvas 1 and then on canvas 2 and you want to stop the storyboard for canvas 1 when that of canvas 2 is running, just call the stop method i.e
C#
cWp2.Stop();
   
Comments
Deaths_eclipsE 21-Aug-11 8:45am
   
Nope. The other canvases start on mouse over and the problem is if i were to accidentally mouse over the other canvas their storyboards will start and mess up everything.
Oludayo Alli 21-Aug-11 9:13am
   
You're starting the storyboard of each canvas on it's MouseOver right? If you MouseOver one canvas, the storyboard starts and if you go ahead to mouseover another canvas, it's Storyborad also start which messes things up right? If this is the case, I will suggest the follow:

1. When Storyboard for canvas 1 start, stop the Storyboard of canvas 2&3
2. When Storyboard for canvas 2 start, stop the Storyboard of canvas 1&3
3. When Storyboard for canvas 3 start, stop the Storyboard of canvas 1&2

Try this and see if it is the desired result.
Deaths_eclipsE 22-Aug-11 6:57am
   
I am doing it but it won't work. After all i think the .Stop() method only will effect the storyboard if it is running. I tried using is statements but i aloso couldn't get the correct code. Anyway thanks for helping.
Oludayo Alli 22-Aug-11 7:38am
   
If you can prepare a demo version of your project, you can upload it and I may be able to help better.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900