how to set wpf MessageBox.Owner to desktop window because SplashScreen closes MessageBox

前端 未结 7 882
有刺的猬
有刺的猬 2020-12-16 00:30

I am using the SplashScreen feature in WPF by setting a bitmap\'s Build Action to Splashscreen. Behind the splash screen, licensing informa

7条回答
  •  攒了一身酷
    2020-12-16 00:46

    I came up with this solution myself, so maybe there's something wrong with it, but it seems to work perfectly:

    Window temp = new Window() { Visibility=Visibility.Hidden };
    temp.Show();
    MessageBox.Show(temp, "An error occurred before the application could start.\n\nTechnical Details: " + ex.Message, "Fatal Error", MessageBoxButton.OK, MessageBoxImage.Stop);
    App.Current.Shutdown(1);
    

提交回复
热议问题