Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 756
mans Avatar asked Sep 06 '13 14:09

mans


1 Answers

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;
}
like image 159
Sheridan Avatar answered Sep 23 '22 02:09

Sheridan