title: What's wrong with this image panning algorithm?
body: <p>In response to <a href="https://stackoverflow.com/questions/741956/wpf-pan-zoom-image">this question</a> about zooming and panning in WPF I made the suggestion to use a ScaleTransform and update the RenderTransform origin in the MouseMove event. This works but I'm not happy with the fact that the panning movement does not quite match the mouse. I can see what the problem with this algorithm is, but the correct implementation continues to elude me. </p>
  
  <pre><code>private void image_MouseMove(object sender, MouseEventArgs e)
  {
      if (image.IsMouseCaptured)
      {
          Vector v = start - e.GetPosition(image);
          // this calculates the deltas relative to the original size of the image
          // but does not take into account the transformed size, but transforming the
          // size like image.ActualWidth * scaleTransform.ScaleX does not help
          double deltax = v.X / image.ActualWidth;
          double deltay = v.Y / image.ActualHeight;
  
          image.RenderTransformOrigin = new Point(orgin.X + deltax, orgin.Y + deltay);
      }
  }
  </code></pre>
  
  <p>Any ideas on how I can make this approach work?</p>