• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1552
  • Last Modified:

Silverlight Nested Storyboard: Completed Event not Firing for Children

I am animating an electrical circuit in Silverlight with nested Storyboards, in which two of the nested storyboards need to trigger a C# routine upon completion (to change a switch).  I am only getting the first Completed event (sbOn_Completed); the sbOff_Completed does not fire, and in the second iteration of sbCycle neither Completed events fire.  If there is not a solution to getting these events, is there a way to trigger a C# routine based on the parent storyboard timer ("at 1.818 seconds into sbCycle execute such-and-such event handler routine")?  


            <!-- sbRun is a wrapper storyboard around the sbCycle sb, which repeats twice, with two nested sbs sbOn and sbOff -->
            <Storyboard x:Name="sbRun" >
                <DoubleAnimation Storyboard.TargetName="ttTimeMark" Storyboard.TargetProperty="X" BeginTime="0:0:0.1" Duration="0:0:20.2" From="0"  To="400" RepeatBehavior="1x"/>
                <Storyboard x:Name="sbCycle" BeginTime="0:0:0" Duration="0:0:10" RepeatBehavior="2x" >
                    <Storyboard x:Name="sbOn"  Completed="sbOn_Completed">
                        <DoubleAnimation Storyboard.TargetName="rectangle1" Storyboard.TargetProperty="Width" From="20" To="40" BeginTime="0:0:0" Duration="0:0:1.818" RepeatBehavior="1x" />
                    </Storyboard>
                    <Storyboard x:Name="sbOff" Completed="sbOff_Completed">
                        <DoubleAnimation Storyboard.TargetName="rectangle2" Storyboard.TargetProperty="Width" From="20" To="80"  BeginTime="0:0:1.819" Duration="0:0:8.182" RepeatBehavior="1x" />
                    </Storyboard>
                </Storyboard>
            </Storyboard>
0
misamexp
Asked:
misamexp
  • 2
1 Solution
 
misamexpAuthor Commented:
There has been no feedback on this.  I think Silverlight is fairly new so hopefully the knowledge base for this general area will increase on e-e.  Here is an update:

1.  I have a mistake: the two child Storyboards (sbOn, sbOff) within the parent Storyboard sbCycle are consecutive, with the second one ending exactly at the same time as the parent [sbCycle=10sec = sbOn(1.818) + sbOff(8.182)].  Caution: Be sure all child storyboards end prior to the parent!
2. The "Completed" event for children of the second execution of  sbCycle - they do not fire .  It would be nice to be able to nest storyboards and have a Completed event fired at the end of each child.  (It would also be handy to have a "BeforeStart" event.)
3. In the end I am not using nested storyboards, but just dumping all animations into one long storyboard.  However, this is not cool, as I would like to have a code-behind process execute in the middle of the storyboard based on elapsed time within the storyboard (there may be an easy way to do this but I do not know how).  

I am leaving this open for now. Any suggestions on synchronizing a storyboard with external C# code-behind processes, or on how to manage nested storyboards, would be most appreciated.  I really do think Silverlight is great, and enjoy working with it.
0
 
misamexpAuthor Commented:
In the end I decided to keep the two nested storyboards un-nested and not try to consider the two as subsets of a parent storyboard.  This is worked out ok.  If anyone has ideas as to when nesting storyboards is a good idea and how to syncrhonize the nested objects, it would be of interest.  
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now