title: How can I animate the Margin of a Stackpanel with a storyboard?
body: <p>I would like to use it, but it doesnt't work, I wanna create a tile animation, in code behind, or if you know a project for this gol, pls write me    </p>
  
  <pre><code> Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
                      {
                          while(true){
                          Duration duration = new Duration(TimeSpan.FromSeconds(0.15));
  
                          // Create two DoubleAnimations and set their properties.
                          DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
  
                          myDoubleAnimation1.Duration = duration;
                          myDoubleAnimation1.From = -173
                          myDoubleAnimation1.To = 173;
                          Storyboard sb = new Storyboard();
                          sb.Duration = duration;
  
                          sb.Children.Add(myDoubleAnimation1);
  
                          Storyboard.SetTarget(myDoubleAnimation1, image);
  
                          // Set the attached properties of Canvas.Left and Canvas.Top
                          // to be the target properties of the two respective DoubleAnimations.
                          Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath(StackPanel.MarginProperty));
  
                          // Begin the animation.
                          sb.Begin();}
                      });
  </code></pre>