title: Silverlight Canvas Sizing within a ScrollViewer
body: <p>I am making a Silverlight 4 website with C#. In one of the pages, I want to have two panels beside each other. On the left is a map control and on the right is an image. That is easy enough, but I also want to be able to click on the image and leave PushPin like objects (like the map) so I put the image in a canvas and just draw circles. The problem is that image can be fairly large and I need to be able to scroll the image. I tried several different ways of achieving this, but so far no luck.</p>
  
  <p>The answers to the following post seemed to be like the way to go, but there must be updates to Silverlight that broke it: <a href="https://stackoverflow.com/questions/855334/wpf-how-to-make-canvas-auto-resize/863108#863108">WPF: How to make canvas auto-resize?</a></p>
  
  <p>A <a href="http://themechanicalbride.blogspot.com/2008/11/auto-sizing-canvas-for-silverlight-and.html" rel="nofollow noreferrer">similar solution</a> suggested making the Canvas from scratch, but I ran into the same problem.</p>
  
  <p>Most of my attempts end in displaying as much of the image as possible on the screen, but no scroll bars (still greyed out) or the page just goes white when the image is loaded.</p>
  
  <p>The following is how I am currently selecting the image to load:</p>
  
  <pre><code>        OpenFileDialog dialog = new OpenFileDialog();
          dialog.Filter = "Image Files (*.png, *.jpg)|*.jpg;*.png";
          if(dialog.ShowDialog() == true) {
              BitmapImage bitmap = new BitmapImage();
              FileStream stream = dialog.File.OpenRead();
              bitmap.SetSource(stream);
              TheImage.Source = bitmap;
          }
  </code></pre>