title: Animate window width right to left
body: <p>I am making a sidebar-style app which is located on the left of right side of the screen.
  I am trying to make it look like it's sliding in and out of the screen, but when it's on the right, it slides in from the left still.</p>
  
  <p>I can't find any right to left options regarding window width, so I was hoping to find the answer here.</p>
  
  <p>Here is my current working animation code for left to right:</p>
  
  <pre><code>    public static void AnimateSize(this Window target, double newWidth, EventHandler completed)
      {
          var length = new TimeSpan(0, 0, 0, 0, Settings.Default.AnimationTime);
          var sb = new Storyboard {Duration = new Duration(length)};
  
          var aniWidth = new DoubleAnimationUsingKeyFrames();
  
          aniWidth.Duration = new Duration(length);
  
          aniWidth.KeyFrames.Add(new EasingDoubleKeyFrame(target.ActualWidth,
              KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 00))));
          aniWidth.KeyFrames.Add(new EasingDoubleKeyFrame(newWidth, KeyTime.FromTimeSpan(length)));
  
          Storyboard.SetTarget(aniWidth, target);
          Storyboard.SetTargetProperty(aniWidth, new PropertyPath(FrameworkElement.WidthProperty));
  
          sb.Children.Add(aniWidth);
  
          sb.Completed += completed;
          sb.Begin();
      }
  </code></pre>
  
  <p>called like this:</p>
  
  <pre><code>_window.AnimateSize(0, delegate { _window.Hide(); });
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>_window.Width = 0;
  _window.Show();
  _window.AnimateSize(Settings.Default.Width, delegate { });
  </code></pre>
  
  <p>Thanks.</p>