title: Sliding elements in c# UWP
body: <p>I have a question about animations in UWP. I want to have a menu on the bottom of my app that, when tapped on the top, slides up (shows) or down (hides almost entirely). I was learning WPF before and there I know I can use ThicknessAnimation to move the margin of my control and have it slide. Unfortunately, in UWP I can't use ThicknessAnimations, so I tried to find another way. I want this to work for an arbitrary FrameworkElement (so as to be able to reuse it). Eventually, I came up with this solution:</p>
  
  <pre><code>    /// &lt;summary&gt;
      /// Adds a vertical slide animation
      /// &lt;/summary&gt;
      /// &lt;param name="storyboard"&gt;The storyboard to add the animation to&lt;/param&gt;
      /// &lt;param name="seconds"&gt;The time the animation will take&lt;/param&gt;
      /// &lt;param name="offset"&gt;The distance the element will cover (nagative is up, positive is down)&lt;/param&gt;
      public static void AddVerticalSlide(this Storyboard storyboard, FrameworkElement element, float seconds, double offset)
      {
  
          var slideAnimation = new ObjectAnimationUsingKeyFrames();       
  
          for (int i = 0; i &lt;= 100; ++i)
          {
              double scalar = (double)i / 100;
              slideAnimation.KeyFrames.Add(new DiscreteObjectKeyFrame
              {                   
                  Value = new Thickness(0, scalar*offset, 0, -scalar*offset),
                  KeyTime = TimeSpan.FromSeconds(scalar*seconds),
              });
          }   
  
          //slideAnimation.Duration = TimeSpan.FromSeconds(seconds);
  
          // Set the target and target property
          Storyboard.SetTarget(slideAnimation, element);
          Storyboard.SetTargetProperty(slideAnimation, "(FrameworkElement.Margin)");
  
          // Add the animation to the storyboard
          storyboard.Children.Add(slideAnimation);
      }
  </code></pre>
  
  <p>It works, looks nice, but here's the reason I'm asking this question: I don't know if it's proper. My guees is that there's a better way to slide objects than manually define 100 points on the way and move the object to each point using this animation.</p>