mans mans - 4 years ago 261
C# Question

Application MainWindow is null in WPF (using Caliburn Micro)

I am developing a WPF application and I need to get a point to the main window of application inside a control. I am using Caliburn Micro.

Application.Current.MainWindow
is
null


How can I get a reference to the
MainWindow
of application in Caliburn Micro?

Answer Source

That's funny, I've just answered this in another post... Try setting the Application.Current.MainWindow property in the Loaded event in the MainWindow.xaml.cs file:

private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Application.Current.MainWindow = this;
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download