Search code examples
c#wpfeventsevent-handlingloaded

How to know if window has finished loading?


I am building an app using WPF and I have 2 animations I want to have delay between them. but when I try to that in the

MainWindow_Loaded(object sender, RoutedEventArgs e)

event, it just delays while loading and I miss the 1st animation.

any help?


Solution

  • There is unfortunately no built-in notification that informs you that loading (binding-rendering) finished. So should come up with your own solution.

    One could be in MainWindow_Loaded write something like this (a pseudocode):

    new Thread(new ThreadStart(new Action(() =>
    {
          Sleep(2000); // a couple of seconds sleep 
          StartAnimation(); 
    
    }))).Start();
    

    Hope this helps.