title: Putting Canvas Inside Viewbox in Silverlight With Image
body: <p>All,</p>
  
  <p>I'm trying to make the silverlight app I'm making resize in a reasonable manner. To do this, I thought I would use a dynamic grid. In the center of the grid I need to put an image inside of a canvas because I will dynamically be positioning objects on top of it. Ideally, as the user makes the browser window larger, the center column would be able to resize and grow larger, thereby growing the image.</p>
  
  <p>Here's what I've got:</p>
  
  <pre><code>&lt;Viewbox Grid.Row="0" Grid.Column="1"&gt;
      &lt;Canvas x:Name="cvsCenterPane"&gt;
          &lt;Image x:Name="imgFormImage" MouseLeftButtonDown="imgFormImage_MouseLeftButtonDown" 
                   MouseLeftButtonUp="imgFormImage_MouseLeftButtonUp" MouseMove="imgFormImage_MouseMove" /&gt;
      &lt;/Canvas&gt;
  &lt;/Viewbox&gt;
  </code></pre>
  
  <p>In the code behind, I then set the image source.</p>
  
  <p>Here's my grid definition:</p>
  
  <pre><code>&lt;Grid x:Name="LayoutRoot" Background="DarkCyan" ShowGridLines="True"&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="300" /&gt;
          &lt;ColumnDefinition Width="*" /&gt;
          &lt;ColumnDefinition Width="300" /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="*" /&gt;
          &lt;RowDefinition Height="100" /&gt;
      &lt;/Grid.RowDefinitions&gt;
  </code></pre>
  
  <p>I think there must be some sort of unhandled exception occurring during the construction of the Viewbox because the image does not display at all. What am I doing wrong here? Am I taking the wrong approach?</p>