We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Silverlight Nested Storyboard: Completed Event not Firing for Children

Medium Priority
Last Modified: 2012-05-11
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 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" />
Watch Question


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.
Unlock this solution and get a sample of our free trial.
(No credit card required)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.