title: Caliburn.Micro - doing something when a view becomes visible
body: <p>I am currently getting into WPF and Caliburn.Micro ,for now without something like MEF or Autofac.</p>
  
  <p>Right now i am trying to execute some code in a viewmodel right after its view becomes visible.</p>
  
  <p>In a related tutorial this code displays a messagebox just before a view is shown:</p>
  
  <pre><code>protected override void OnActivate() 
  {   
      MessageBox.Show("Page Two Activated"); //Don't do this in a real VM.   
      base.OnActivate();   
  }  
  </code></pre>
  
  <p>Mr. Eisenberg then writes this:</p>
  
  <blockquote>
    <p>Remember, if you have any activation logic that is dependent on the
    view being already loaded, you should override Screen.OnViewLoaded
    instead of/in combination with OnActivate.</p>
  </blockquote>
  
  <p>This is what i have:</p>
  
  <pre><code>protected override void OnViewLoaded(object view)
  {
      base.OnViewLoaded(view);
      MessageBox.Show("OnPageTwoViewLoaded");
  }
  </code></pre>
  
  <p>I also tried it via a Grid EventTrigger and a cal:ActionMessage.
  But in all three cases the MessageBox appears before the view is visible.</p>
  
  <p>Surely i am missing something, what am i doing wrong?</p>