title: Slide in & Slide out animation
body: <p>I am trying to make a slide in &amp; out animation with c# &amp; WPF.</p>
  
  <p>So far I have managed to code the next lines:</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Grid Name="grid" Grid.Column="0" Grid.Row="1"&gt;
         &lt;Border Name="border" Background="Red"&gt;&lt;/Border&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>c#:</p>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e) {
              border.Height = grid.ActualHeight;
              if (!isOpen) {
                  isOpen = true;
                  DoubleAnimation db = new DoubleAnimation();
                  db.From = 0;
                  db.To = grid.ActualHeight;
                  db.Duration = TimeSpan.FromSeconds(0.5);
                  border.BeginAnimation(Grid.HeightProperty, db);
              } else {
                  isOpen = false;
                  DoubleAnimation db = new DoubleAnimation();
                  db.From = grid.ActualHeight;
                  db.To = 0;
                  db.Duration = TimeSpan.FromSeconds(0.5);
                  border.BeginAnimation(Grid.HeightProperty, db);
              }
          }
  </code></pre>
  
  <p>The good thing is that the animation is executed. The bad thing is that this animation has the wrong effect, i mean the animation goes from top to middle and bottom to middle (like if it was shrinking)...</p>
  
  <p>How can i make (or modify in my actual code) the slide effect(top to bottom &amp; bottom to top)? </p>
  
  <p>It has to be in c# code.</p>