Performing Animation with Silverlight Support RRS feed

  • Question

  • I have a slider and an vector of a lightbulb. The lightbulb has a timeline named "" that animates the light going from dim to bright. My boss cannot make any of my timelines stop on a certain frame through his code so I am trying to make it possible through another way. He said that I need to name the thing that controls the dim to brightness. I am not really sure what he means by that but here is my code/storyboard:

    <Storyboard x:Key="lightAnimate">
       <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Path_6" Storyboard.TargetProperty="(UIElement.Opacity)">
        <DiscreteDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
        <SplineDoubleKeyFrame KeyTime="00:00:03" Value="1"/>
        <SplineDoubleKeyFrame KeyTime="00:00:06" Value="0"/>

    Now this is an example from the book "Silverlight 1.0 Unleashed"

    <Canvas xmlns="http://schemas.microsoft.com/clint/2007">
    <Rectangle Name = "rectangle" Width="50" Height="50" Fill="Red" Stroke="Black"
    <EventTrigger RoutedEvent="Rectangle.Loaded">
    <Storyboard Storyboard.TargetProperty="Width"
    <DoubleAnimation From="50" To="100" Duration="0:0:1"/>

    So I think I need to get mine to work somewhat like the book example so he can control it from his code. Can someone please show me how my code needs to look? I am a designer and not the greatest with code.
    Designer Girl
    Tuesday, May 20, 2008 2:18 PM

All replies

  • Anyone good with code?
    Designer Girl
    Thursday, May 22, 2008 5:14 PM
  • First off I am no expert here but as no one has answered then I will give it a go and if its not correct it may prompt others to reply.

    I am not totally sure what you want or what code you boss is using so my reply is based on what I would do.

    I would split up the storyboard into two storyboards - 0 - 1 brightness for the lightbulb x:Key = "bulbBright' and 1 - 0 x:Key = "bulbDim" - placing both sb's into resources.

    In c# I would set up two storyboards and use 

    private Storyboard bBright;

    bBright = (Storyboard) FindResource("bulbBright");

    I would then control the storyboards using Begin etc.

    Alternatively you can set the event up in the xaml directly onto the storyboard such as Completed="xxxx" where xxxx is the name of the event you will trigger.

    I am guessing here that SL even though its cut down works with this kind of stuff, if not then a real expert may pop in to help.

    Thursday, May 22, 2008 7:46 PM