title: Animating two UIElements at the same time using WPF C#
body: <p>I have these two animations here, one to close a slide out grid navigation menu, and the other to set a rectangles fill to transparent as that menu closes.</p>
  
  <p>I would like these to both happen at the same time. Right now the animations happen in the order they are invoked.</p>
  
  <p>How can I implement this as simple and clean as possible using C# code? I am only creating this application to learn about animations and different ways layout controls.</p>
  
  <pre><code>private void _CloseSlideGrid()
  {
      DoubleAnimation da = new DoubleAnimation();
      da.Duration = TimeSpan.FromSeconds(0.3d);
      da.DecelerationRatio = 1.0d;
      da.From = 500.0d;
      da.To = 0.0d;
      _slideGrid.BeginAnimation(Grid.WidthProperty, da);
  }
  
  private void _DisableTransparentCover()
  {
      BrushAnimation ba = new BrushAnimation();
      ba.Duration = TimeSpan.FromSeconds(0.3d);
      ba.DecelerationRatio = 1.0d;
      ba.From = _GetBrush("#77000000");
      ba.To = _GetBrush("#00000000");
      _tranparentCover.BeginAnimation(Rectangle.FillProperty, ba);
  }
  </code></pre>
  
  <p>An event callback for my close button invokes my two private functions that will handle the animations.</p>
  
  <pre><code>private void _NavCloseButton_Click(object sender, RoutedEventArgs e)
  {
      _CloseSlideGrid();
      _DisableTransparentCover();
  }
  </code></pre>
  
  <p>Here is a link to an Imgur album with a screenshot of the two states of my window, if you are intrested:
  <a href="http://imgur.com/a/ZaSr1" rel="nofollow">http://imgur.com/a/ZaSr1</a></p>
  
  <p>Let me know if I can provide any more information,</p>
  
  <p>Thanks.</p>