title: Get the height/width of Window WPF
body: <p>I have the following code</p>
  
  <pre><code>&lt;Window x:Class="Netspot.DigitalSignage.Client.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" WindowStyle="SingleBorderWindow" 
          WindowStartupLocation="CenterScreen"
          WindowState="Normal" Closing="Window_Closing"&gt;
  </code></pre>
  
  <p>Any attempt to get the height / width return NaN or 0.0</p>
  
  <p>Can anyone tell me a way of getting it ?</p>
  
  <p>These 2 methods don't work</p>
  
  <pre><code>//Method1
  var h = ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualHeight;
  var w = ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualWidth;
  
  //Method2
  double dWidth = -1;
  double dHeight = -1;
  FrameworkElement pnlClient = this.Content as FrameworkElement;
  if (pnlClient != null)
  {
       dWidth = pnlClient.ActualWidth;
       dHeight = pnlClient.ActualWidth;
  }
  </code></pre>
  
  <p>The application will not be running full screen.</p>