title: WPF Control actual size
body: <p>I have this piece of XAML code:</p>
  
  <pre><code>&lt;Window x:Class="SizingTest.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Window1" Height="300" Width="300"&gt;
      &lt;Grid&gt;
          &lt;Label x:Name="theLabel" Width="Auto"&gt;A very large label with a lot of text&lt;/Label&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>In the code behind, I'm trying to get the label's actual width, I thought</p>
  
  <pre><code>theLabel.ActualWidth
  </code></pre>
  
  <p>would do the trick, but after trying this code:</p>
  
  <pre><code>public Window1()
  {
      InitializeComponent();
      double width = theLabel.ActualWidth;
  }
  </code></pre>
  
  <p>The value of width is 0, I also checked with theLabel.Width, which returns NaN, theLabel.DesiredSize.Width, which also return 0. What can I use to find the real width of the label?</p>
  
  <p>Thank you.</p>