System.Windows.MessageBox doesn't wait for user input before going poof!

后端 未结 7 1564
轻奢々
轻奢々 2021-01-08 00:56

...and it makes no sense why. T-T

In my Application_Startup event handler I have code that looks kinda like this:

private void Applicati         


        
相关标签:
7条回答
  • 2021-01-08 01:36

    The message box vanishes immediately because it has no owner. If you specify the option MessageBoxOptions.DefaultDesktopOnly, the desktop will be assigned as the owner, and the message box will work correctly on an application with no main window.

    MessageBox.Show(
        "Message", 
        "Title",
        MessageBoxButton.YesNoCancel, 
        MessageBoxImage.Question, 
        MessageBoxResult.Cancel,
        MessageBoxOptions.DefaultDesktopOnly);
    
    0 讨论(0)
提交回复
热议问题