title: C# WPF Window: Wrong Width and ActualWidth values
body: <p>I just wrote a small program in C# that displays quotations on my desktop. My problem is to center the window of the application. To calculate the wanted location of the window i'm using this formula:</p>
  
  <pre><code>        Left = (Screen.PrimaryScreen.Bounds.Width - this.ActualWidth) / 2;
          Top = (Screen.PrimaryScreen.Bounds.Height - this.ActualHeight) / 2;
  </code></pre>
  
  <p>Unfortunately this.ActualWidth and this.ActualHeight give wrong values as you can see in the screenshot. 188,4 and 189 instead of 1000(+).</p>
  
  <p><a href="http://www.directupload.net/file/d/4044/4x2tgadg_png.htm" rel="nofollow">http://www.directupload.net/file/d/4044/4x2tgadg_png.htm</a></p>
  
  <p>Here is the GUI:</p>
  
  <p><a href="http://www.directupload.net/file/d/4044/63rx2sul_png.htm" rel="nofollow">http://www.directupload.net/file/d/4044/63rx2sul_png.htm</a></p>
  
  <p>The code in text form:</p>
  
  <pre><code>public partial class QuotePresenter : Window
  {
      public QuotePresenter()
      {
          InitializeComponent();
          setSize();
      }
  
      private void setSize()
      {
          MaxWidth = Screen.PrimaryScreen.Bounds.Width * 0.8;
          MaxHeight = Screen.PrimaryScreen.Bounds.Height * 0.8;
      }
  
      private void setLocation()
      {
          Left = (Screen.PrimaryScreen.Bounds.Width - this.ActualWidth) / 2;
          Top = (Screen.PrimaryScreen.Bounds.Height - this.ActualHeight) / 2;
  
          System.Windows.MessageBox.Show("Actual Width: " + this.ActualWidth + "\nWidth: " + this.Width);
      }
  
      public void SetQuote(Quotation quote)
      {
          Dispatcher.Invoke(new Action(() =&gt;
          {
              tb_content.Text = quote.Content;
              tb_author.Text = "- " + quote.Author;
  
              setLocation();
          }));
      }
  }
  </code></pre>
  
  <p>Can somebody tell me what went wrong here?</p>
  
  <p>Thanks in advance! </p>