1

I need to call a method the first thing after the MainWindow is built. I've added this code to the XAML:

Loaded="MainWindow_Loaded"

And this method to MainWindow:

void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    SelectScenario dlg = new SelectScenario();
    dlg.Top = 22;
    dlg.ShowDialog();
    if (ScenarioSelected == true)
    {
        LoadScenarioFile(SelectedScenario);
    }
}

But the SelectScenario dialog box is being called before the MainWindow is fully built. Where can I insert the method call for the SelectScenario dialog box so I know the MainWindow has been completely built?

zetar
  • 1,225
  • 2
  • 20
  • 45
  • You might need to wait for all contents to have loaded – H.B. Jun 30 '16 at 18:19
  • Okay, how can I check to know all contents have been loaded? – zetar Jun 30 '16 at 18:20
  • Well, i don't know. I think relying on the state of this UI in this way is not a good idea. I would try to get around having to do this in the first place. – H.B. Jun 30 '16 at 18:21
  • Well, this is basically a splash screen and it fits into a section of main window. I just need to know that the main window is built and then call this dialog box. – zetar Jun 30 '16 at 18:26

1 Answers1

5

There's an event called "ContentRendered" you could try this instead of loaded.

Dark Templar
  • 1,130
  • 8
  • 10