title: Scrollviewer & Canvas
body: <p>I am trying to load an image within a canvas such that, if the size of image overflows the canvas, the scroll bars should get activated (MS Paint style)</p>
  
  <pre><code>&lt;Window&gt;
     &lt;ScrollViewer&gt;
          &lt;Canvas  ScrollViewer.HorizontalScrollBarVisibility="Visible" 
                   ScrollViewer.VerticalScrollBarVisibility="Visible"&gt;
              &lt;Image Source="SampleImage.jpg" /&gt;
          &lt;/Canvas&gt;
     &lt;/ScrollViewer&gt;
   &lt;/Window&gt;
  </code></pre>
  
  <ul>
  <li>Now as <code>Canvas</code> is stretched to <code>Window</code>'s size, scroll-bars won't appear as <code>Canvas</code> is not actually overflowing out of the <code>Window</code>.</li>
  <li>Secondly, as the <code>Image</code> is much bigger than the <code>Canvas</code>, it is getting clipped at the bounds of <code>Canvas</code>, so <code>ScrollViewer</code> doesn't think that its content: <code>Canvas</code> is actually overflowing.</li>
  </ul>
  
  <p>It happens a lot of time with <code>StackPanel</code>s too, that even though the bound data has tens of rows, but still the scrollbars don't get activated. Sometimes scrollviewers appear as mystery to me.</p>
  
  <p>So, what should be the basic logic kept in mind when using <code>ScrollViewer</code> control.</p>
  
  <p>Thank you.</p>
  
  <p><strong>Edit:</strong> Just edited the question title, so that whosoever has problem with canvas can get this question easily in search.</p>