title: ScaleTransform transforms non-linearly
body: <p>I am using scale transform to allow a user to resize a control.  What happens though is that when you start to move the mouse the control jumps to a new size, and then scales oddly.  The further you move your mouse from the starting location the larger the increase in size becomes.</p>
  
  <p>I expect its the way I calculate the scale to be applied.  Here is the code:</p>
  
  <pre><code>private void ResizeGrip_MouseDown(object sender, MouseButtonEventArgs e)
  {
      ResizeHandle.CaptureMouse();
  
      //Get the initial coordinate cursor location on the window
      initBtmX = e.GetPosition(this).X;
  
      bottomResize = true;
  }
  
  private void ResizeGrip_MouseUp(object sender, MouseButtonEventArgs e)
  {
      bottomResize = false;
      ResizeHandle.ReleaseMouseCapture();
  }
  
  private void ResizeGrip_MouseMove(object sender, MouseEventArgs e)
  {
      if( bottomResize == true)
      {
          //Get the new Y coordinate cursor location
          double newBtmX = e.GetPosition(this).X;
  
  
          //Get the smallest change between the initial and new cursor location
          double diffX = initBtmX - newBtmX;
  
          // Let our rectangle capture the mouse
          ResizeHandle.CaptureMouse();
  
          double newWidth = e.GetPosition(this).X - diffX;
  
          double scaler = newWidth / ResizeContainer.ActualWidth;
  
          Console.WriteLine("newWidth: {0}, scalar: {1}", newWidth, scaler);
  
  
          if (scaler &lt; 0.75 || scaler &gt; 3)
              return;
  
          ScaleTransform scale = new ScaleTransform(scaler, scaler);
  
          ResizeContainer.LayoutTransform = scale;
      }
  }
  </code></pre>
  
  <p><strong><em>Update: Now with XAML</em></strong></p>
  
  <pre><code>&lt;wtk:IToolDialog x:Name="VideoPlayer" ParentControl="{Binding ElementName=Stage}" DialogTitle="Video Player" Margin="90,5,0,0"&gt;
      &lt;Grid&gt; 
          &lt;Grid x:Name="ResizeContainer" ClipToBounds="True" Width="320" Height="240" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,1"&gt;
              &lt;!-- The video frame --&gt;
              &lt;Image Stretch="Fill" Source="{Binding CurrentFrameImage}" x:Name="VideoImage" /&gt;
              &lt;Grid&gt;
                  &lt;pplcontrols:VideoGroundPlane Foreground="Black" GridSize="20" GroundPlane="{Binding GroundPlane}"&gt;
                  &lt;/pplcontrols:VideoGroundPlane&gt;
              &lt;/Grid&gt;
              &lt;Grid x:Name="HitMask" IsHitTestVisible="False"/&gt;
          &lt;/Grid&gt;
          &lt;ResizeGrip Cursor="SizeNWSE" x:Name="ResizeHandle" VerticalAlignment="Bottom" HorizontalAlignment="Right" Mouse.MouseDown="ResizeGrip_MouseDown" Mouse.MouseUp="ResizeGrip_MouseUp" Mouse.MouseMove="ResizeGrip_MouseMove"&gt;&lt;/ResizeGrip&gt;
      &lt;/Grid&gt;
  &lt;/wtk:IToolDialog&gt;
  </code></pre>