title: WPF - sequential animation simple example
body: <p>I'm learning about WPF animation, and am confused about how to apply animations sequentially.  As a simple example, I've got four rectangles in a uniform grid, and would like to change the color of each one sequentially.  Here's what I have so far:</p>
  
  <pre><code>public partial class Window1 : Window
  {
      Rectangle blueRect;
      Rectangle redRect;
      Rectangle greenRect;
      Rectangle yellowRect;
  
      public Window1()
      {
          InitializeComponent();
          blueRect = new Rectangle() { Fill = System.Windows.Media.Brushes.Blue, Name="Blue"};
          redRect = new Rectangle() { Fill = System.Windows.Media.Brushes.Red, Name="Yellow"};
          greenRect = new Rectangle() { Fill = System.Windows.Media.Brushes.Green, Name="Green" };
          yellowRect = new Rectangle() { Fill = System.Windows.Media.Brushes.Yellow, Name="Yellow" };
  
          UniformGrid1.Children.Add(blueRect);
          UniformGrid1.Children.Add(redRect);
          UniformGrid1.Children.Add(greenRect);
          UniformGrid1.Children.Add(yellowRect);
  
      }
  
      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          animateCell(blueRect, Colors.Blue);
          animateCell(redRect, Colors.Red);
      }
  
      private void animateCell(Rectangle rectangle, Color fromColor)
      {
          Color toColor = Colors.White;
          ColorAnimation ani = new ColorAnimation(toColor, new Duration(TimeSpan.FromMilliseconds(300)));
          ani.AutoReverse = true;
  
          SolidColorBrush newBrush = new SolidColorBrush(fromColor);
          ani.BeginTime = TimeSpan.FromSeconds(2);
          rectangle.Fill = newBrush;
          newBrush.BeginAnimation(SolidColorBrush.ColorProperty, ani);
          //NameScope.GetNameScope(this).RegisterName(rectangle.Name, rectangle);
          //Storyboard board = new Storyboard();
          //board.Children.Add(ani);
          //Storyboard.SetTargetName(rectangle, rectangle.Name);
          //Storyboard.SetTargetProperty(ani, new PropertyPath(SolidColorBrush.ColorProperty));
          //board.Begin();
  
      }
  </code></pre>
  
  <p>What's the easiest way of accomplishing this?  The code in the comments is my first guess, but it's not working correctly.</p>