title: Programmatically create silverlight animation with easing in C#
body: <p>I'm messing around with making a clock in silverlight. I am trying to set up the animation code programmatically because I want to reuse the same code for each of the 3 clock hands (and I don't think I can do this with a single storyboard in xaml).</p>
  
  <pre><code>        public void Rotate(double toAngle, RotateTransform rotate)
      {
          Storyboard sb = new Storyboard();
  
          DoubleAnimationUsingKeyFrames keyframes = new DoubleAnimationUsingKeyFrames();
  
          EasingDoubleKeyFrame easingStart = new EasingDoubleKeyFrame();
          easingStart.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0));
          easingStart.Value = rotate.Angle;
  
          EasingDoubleKeyFrame easingEnd = new EasingDoubleKeyFrame();
          easingEnd.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5));
          easingEnd.Value = toAngle;
          var ease = new ElasticEase();
          ease.EasingMode = EasingMode.EaseIn;
          easingEnd.EasingFunction = ease;
  
          keyframes.KeyFrames.Add(easingStart);
          keyframes.KeyFrames.Add(easingEnd);
  
          Storyboard.SetTarget(keyframes, rotate);
          Storyboard.SetTargetProperty(keyframes, new PropertyPath("(RotateTransform.Angle)"));
  
          sb.Children.Add(keyframes);
          sb.Begin();
      }
  </code></pre>
  
  <p>I pass in both the angle I want the current hand to rotate to and the rotate transform for that hand. From this rotate transform I get the starting angle.</p>
  
  <p>When I run the clock, the clock hands move (the second hand moves to the correct spot each second etc) but the animations don't appear to actually animate. They just go from start to end instantly.</p>
  
  <p>Why does the animation not happen properly?</p>