title: Zoom Out Image to fit ScrollViewer Dimensions
body: <p>I have a little issue with zooming accordingly an image. I have an <code>Image</code> in my XAML, with a <code>ScrollViewer</code> attached so it can be zoomed. Like this :</p>
  
  <pre><code>&lt;ScrollViewer x:Name="ImageScrollViewer"&gt;
      &lt;Image x:Name="ImagePanel" 
             Stretch="Uniform" 
             VerticalAlignment="Center" 
             HorizontalAlignment="Center"/&gt;
  &lt;/ScrollViewer&gt;
  </code></pre>
  
  <p>What I'd like to do is that, in case the image is too big to fit the image control and needs to be zoomed out (only in this case), I'd like to programatically set the ZoomFactor of the ScrollViewer so it fits the Image control. My problem is, I don't really know how could I determine that factor, considering my image's width and height.</p>
  
  <p>Also I'd like not to scale the picture, to change it in any way, I'd seen some similar topics on SO for this issue but so far, none have applied to my case. I just need to zoom out my picture until there's no vertical/horizontal scrollbars visible.</p>
  
  <p>Any suggestions on how to do this, are greatly appreciated, thank you!</p>