title: Window Top and Left values are not updated correctly when maximizing a Window in .NET 4
body: <p>I am trying to center a Window to the owner window. I also need the child window to move along the owner window. A cross-post on the MSDN WPF forum's can be found <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/078b8a70-7725-4986-8164-55efccbcfb46">here</a>.</p>
  
  <p>To achieve this I subscribe to the <code>LocationChanged</code> and <code>SizeChanged</code> events (and also the <code>StateChanged</code> event) of the owner of my child window. When those events are triggered I recompute the location of child window. I do this in the code-behind of the child window.</p>
  
  <p>The code is very straight forward:</p>
  
  <pre><code>Top = Owner.Top + ((Owner.ActualHeight - ActualHeight) / 2);
  Left = Owner.Left + ((Owner.ActualWidth - ActualWidth) / 2);
  </code></pre>
  
  <p>If you compile and run the sample program I provided you will see that it works when the main window is as-is, and moved around. So that part works.</p>
  
  <p>The problem arises when the owner window is maximized. (And after being maximized, set back to normal.) Because I subscribe to three events I enter the relocate function three times. After printing out the owner data I get different results. Most annoyingly the <code>Top</code> and <code>Left</code> values of the owner window are off. It seems it gets the correct Top and Left values when the state changes, but then the <code>ActualWidth</code> and <code>ActualHeight</code> values are wrong. When the <code>LocationChanged</code> or <code>SizeChanged</code> events are triggered the <code>ActualWidth</code> and <code>ActualHeight</code> values are OK, but the Top and Left values are incorrect. It seems these are the previous values. How can this be? What is causing this? And is there a proper fix for this?</p>
  
  <p>Since the same code seemed to have worked in .net 3.5 I am under the impression something changed in .net 4. (Or I had a weird timing issue which caused the problem not to appear.) But I cannot find any documented change in this part.</p>
  
  <p>.NET 3.5:</p>
  
  <pre><code>OnOwnerLocationChanged
  T: -8; L: -8; W: 640; H: 480
  OnOwnerStateChanged
  T: -8; L: -8; W: 640; H: 480
  OnOwnerSizeChanged
  T: -8; L: -8; W: 1936; H: 1066
  </code></pre>
  
  <p>.NET 4.0:</p>
  
  <pre><code>OnOwnerLocationChanged
  T: -8; L: -8; W: 640; H: 480
  OnOwnerStateChanged
  T: 494; L: 33; W: 640; H: 480
  OnOwnerSizeChanged
  T: 494; L: 33; W: 1936; H: 1066
  </code></pre>
  
  <p>So the main question remains: why are the Top and Left values of the owner incorrect?</p>