title: Storyboard.SetTargetProperty not working under Windows phone 8.1?
body: <p>I have the following extension method that I am using from a <a href="http://www.scottlogic.com/blog/2012/06/06/a-gesture-driven-windows-phone-to-do-application.html" rel="nofollow noreferrer">gesture example app I found online</a> for Windows Phone 7. I am trying to migrate it to 8.1 for my app, but have run in to problems with the <code>Storyboard.SetTargetProperty</code> method invocation. It appears that <a href="https://stackoverflow.com/a/25424850/1815321">this signature is not supported</a> in Windows 8.1. </p>
  
  <p>I am fairly new to Windows Phone development in general and not sure what I should use in place of this, can someone point me to a method in the API that provides what this is trying to achieve? It appears that the signature now requires a string, where previously a PropertyPath was allowed. I'm not sure what I need to do to transform a DP property into a string that represents it, will a string set to the name of the DP property work?</p>
  
  <pre><code>public static void Animate(this DependencyObject target, double from, double to,
                          object propertyPath, int duration, int startTime,
                          Action completed = null)
  {
      var db = new DoubleAnimation();
      db.To = to;
      db.From = from;
      db.EasingFunction = new SineEase();
      db.Duration = TimeSpan.FromMilliseconds(duration);
      Storyboard.SetTarget(db, target);
  
      // Compiler error: This method signature is no longer supported.
      Storyboard.SetTargetProperty(db, new PropertyPath(propertyPath));
  
      var sb = new Storyboard();
      sb.BeginTime = TimeSpan.FromMilliseconds(startTime);
  
      if (completed != null)
      {
          sb.Completed += (s, e) =&gt; completed();
      }
  
      sb.Children.Add(db);
      sb.Begin();
  }
  </code></pre>
  
  <p><strong>Invoked like this</strong></p>
  
  <pre><code>TranslateTransform elementTrans = new TranslateTransform();
  elementTrans.Animate(0, elementOffset, TranslateTransform.YProperty, 200, startTime, null, action);
  </code></pre>
  
  <p>Not sure how to transform the <code>TranslateTransform.YProperty</code> in to a string that can be passed in to the <code>SetTargetProperty</code> call.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I <a href="http://msdn.microsoft.com/en-us/library/windows.ui.xaml.media.animation.storyboard.settargetproperty.aspx" rel="nofollow noreferrer">have found some documentation on MSDN</a> that shows how to pass the property name in via a string. I don't think that I am providing it correctly though as I get a runtime exception that it can't find the property provided.</p>
  
  <pre><code>        transform.Animate(transform.X, 0, "(FrameworkElement.RenderTransform).(TranslateTransform.XProperty)", 300, 0, new BounceEase()
          {
              Bounciness = 5,
              Bounces = 2
          });
  </code></pre>
  
  <p>Note that I changed the method signature to accept a string for <code>propertyPath</code> instead of an object, but did not reflect that here as I wanted to keep the original source above as-is from my original post.</p>
  
  <p>The <code>RenderTransform</code> is set to a <code>TranslateTransform</code> like this:</p>
  
  <pre><code>    public static void SetHorizontalOffset(this FrameworkElement element, double offset)
      {
          var transform = new TranslateTransform { X = offset };
          element.RenderTransform = transform;
          element.Tag = new Offset { Value = offset, Transform = transform };
      }
  </code></pre>