title: Waiting for storyboard animation to finish before changing view in Silverlight 4 using MVVM
body: <p>I have a login page in Silverlight 4. I am using MVVM to handle all interactions with the page. On successful login I have a custom event that fires in my view model followed by code to navigate to the main page. I use event aggregation, publish &amp; subscribe for navigating between views.</p>
  
  <pre><code> AnimateLoginSuccess(this, null);
  //code to navigate to the main page after successful login.
  </code></pre>
  
  <p>I handle this event in my view, wiring it up like this, where LoginSuccessStoryboard is the storyboard I have created for some basic animation:</p>
  
  <pre><code>    //constructor of view
      public Login(LoginVM vm)
      {
          InitializeComponent();
  
          DataContext = vm;
          thisVM = vm;
  
          vm.AnimateLoginSuccess += new EventHandler(vm_AnimateLoginSuccess);
  
      }
  
  
  //event handling method in view
      void vm_AnimateLoginSuccess(object sender, EventArgs e)
      {
          LoginSuccessStoryboard.Begin();
      }
  </code></pre>
  
  <p><strong>Now</strong>, the problem is, even though the animation begins after successful login, the next lines that handle moving to a different view on successful login make the moving to the next view so fast that it doesn't wait for the animation to finish. Thereby making the animation virtually non-existant. Any ideas on how to make this work? </p>