title: XAML: accessing actual width and height
body: <p>I have a viewbox with an image inside:</p>
  
  <pre><code>&lt;Viewbox MaxHeight="100" MaxWidth="100" x:Name="Scenario4ImageContainer2" Stretch="Uniform" Grid.Column="1" Grid.Row="1"&gt;
      &lt;Image x:Name="Scenario4Image" PointerPressed="Scenario4Image_PointerPressed" HorizontalAlignment="Stretch"  /&gt;
  &lt;/Viewbox&gt;
  </code></pre>
  
  <p>I want to be able to grab the actual width/height values, but when I try this in the backend C#:</p>
  
  <pre><code>int w = (int)Scenario4ImageContainer.Width
  </code></pre>
  
  <p>I get an error saying the parameter is incorrect.</p>
  
  <p>This goes away if I hardcode the width, but I want it to resize dynamically.</p>
  
  <p>I also tried grabbing Scenario4ImageContainer.ActualWidth but this parameter was "incorrect" as well.</p>