title: How to not drag an Image out of the frame?
body: <p>I cannot find the property or the object that I need..</p>
  
  <p>I have implemented a draggable and zoomable image but I can drag it out of the screen, so I lose my Image out of the view.</p>
  
  <p>Where should I put my image to keep it inside a box (and, possibly with the nice bouncing effect)?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Pratically my image has to remain in the stackpanel, with only the possibility of zoom-in.
  (max zoom-out as the first rendering).</p>
  
  <p>A bit of code:</p>
  
  <pre><code>    private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
      {
          initialAngle = compositeTransform.Rotation;
          initialScale = compositeTransform.ScaleX;
      }
  
      private void OnPinchDelta(object sender, PinchGestureEventArgs e)
      {
          compositeTransform.ScaleX = initialScale * e.DistanceRatio;
          compositeTransform.ScaleY = initialScale * e.DistanceRatio;
      }
  
      private void OnDragDelta(object sender, DragDeltaGestureEventArgs e)
      {
          compositeTransform.TranslateX += e.HorizontalChange;
          compositeTransform.TranslateY += e.VerticalChange;
      }
  
      &lt;StackPanel x:Name="container"&gt;
          &lt;Image x:Name="image_chart"&gt;
              &lt;Image.RenderTransform&gt;
                  &lt;TransformGroup&gt;
                      &lt;ScaleTransform x:Name="scale" /&gt;
                      &lt;TranslateTransform x:Name="transform" /&gt;
                      &lt;CompositeTransform x:Name="compositeTransform"/&gt;
                  &lt;/TransformGroup&gt;
              &lt;/Image.RenderTransform&gt;
              &lt;toolkit:GestureService.GestureListener&gt;
                  &lt;toolkit:GestureListener PinchStarted="OnPinchStarted" PinchDelta="OnPinchDelta"
                                           DragDelta="OnDragDelta"/&gt;
              &lt;/toolkit:GestureService.GestureListener&gt;
          &lt;/Image&gt;
      &lt;/StackPanel&gt;
  </code></pre>
  
  <p><strong>EDIT 2 - Half Answer</strong></p>
  
  <p>I've finally find out how to stop the zoom-out at the original size!</p>
  
  <pre><code>private void OnPinchDelta(object sender, PinchGestureEventArgs e)
      {
          if (1.0 &lt;= (initialScale * e.DistanceRatio))
          {
              compositeTransform.ScaleX = initialScale * e.DistanceRatio;
              compositeTransform.ScaleY = initialScale * e.DistanceRatio;
          }
      }
  </code></pre>
  
  <p>The If condition means: if I'm zooming in -> no problem because the e.DistanceRatio is >1. If I'm zooming out I will stop until the initialScale will be the same!</p>
  
  <p>Now I still need help on how avoid the Drag outside.</p>