title: what WPF method can I use to set some properties on a control's first display?
body: <p>I need to store my app window's size/position and state when the user closes the app and set them back when the user thereafter opens the app.</p>
  
  <p>I did this easily using registry keys (is this even the best way to do?), but I'm wondering where I actually should put the code to set those properties.</p>
  
  <p>I need to set them when the window first "appears" I think. But I have several methods that could be used in this case, namely:</p>
  
  <ul>
  <li>Window.Show()</li>
  <li>Window.Activate()</li>
  <li>Window.ApplyTemplate()</li>
  <li>Window.Arrange()</li>
  <li>Window.ArrangeCore()</li>
  <li>Window.ArrangeOverride()</li>
  <li>Window.BeginInit()</li>
  <li>Window.EndInit()</li>
  <li>Window.Measure()</li>
  <li>Window.MeasureCore()</li>
  <li>Window.MeasureOverride()</li>
  <li>Window.OnApplyTemplate()</li>
  <li>Window.OnInitialized()</li>
  <li>Window.OnRender()</li>
  <li>Window.UpdateLayout()</li>
  </ul>
  
  <p>I'm aware that most of them just are a bad idea (UpdateLayout() will be called waaaaaaay too often for instance). Idealy I'm looking for a method that will only be called once in the window's life so that I don't have to add a flag checking if this is the method's first call.</p>
  
  <p>so which one would be the best in this case? and why?</p>
  
  <p>side question: I put the code to save the values in Window.Close() (I'm overriding the method in my <code>MyWindow</code> class), But I could as well have put it in Window.OnClosing() or Window.OnClosed(). Does this make any difference in my case?</p>
  
  <p>side question (bis): I also have to save a datagrid's column order, where should I put both "saving" and "loading" code in this case?</p>