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

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


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);


Based on Alexey Ivanov's suggestion, I successfully used a new window as the parent

System.Windows.Forms.MessageBox.Show(new System.Windows.Forms.NativeWindow(), errorMessage, "Application Startup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);


Try to use an overload that accepts System.Windows.Window parameter and pass Null value to make your MessageBox a top-level window of your application, which is independent of all other windows that may exist. I guess your MessageBox gets owned by splashscreen form. When splashscreen is closed, the framework closes the MessageBox. So making your MessageBox ownerless should do the trick.