title: Find Height of Textblock / Text
body: <p>i try to calculate the height of <a href="http://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.textblock.aspx" rel="nofollow noreferrer">TextBlock</a>.
  I dont want to take the Textblock on some page. I just have to know the height of my Content.</p>
  
  <p>I tried it this way, but it just returns 0</p>
  
  <pre><code>private static double CalculateContentHeight(string content, double width, double fontSize)
  {
      //Nur einen Textblock ggf. um Ressourcen zu sparen
      TextBlock textblock = new TextBlock
      {
          FontSize = fontSize,
          Text = content,
          TextWrapping = TextWrapping.Wrap,
          MaxWidth = width,
          Height = Double.NaN
  
      };
      return textblock.ActualHeight;
  }
  </code></pre>
  
  <p>If i take a existing TextBlock in XAML and just:</p>
  
  <pre><code>MyXAMLTextBlock.MaxWidth = 7;
  double height = MyXAMLTextBlock.ActualHeight;
  </code></pre>
  
  <p>I get the right value for it. </p>
  
  <p>I know there are possibilitys with Meassure() and Arrange() like in this <a href="https://stackoverflow.com/questions/10556019/how-to-calculate-the-textbock-height-and-width-in-on-load-if-i-create-textblock">Example</a>, but Meassure(Size) takes the size paramter and i dont have the height for it.</p>
  
  <p>I know that you can set the size on Auto with Double.Nan, but it doesnt compile with</p>
  
  <pre><code>double height = 9;
  Size s = new Size(height, Double.Nan);
  </code></pre>
  
  <p>Maybe you can help me and thanks a lot.</p>