This project has moved and is read-only. For the latest updates, please go here.

MessageBox only opens once

Mar 22, 2016 at 1:43 PM
Edited Mar 22, 2016 at 1:47 PM

Ive started using your messagebox to be able to style my messageboxes.

Xceed.Wpf.Toolkit.MessageBox.Show(message, caption, MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

The first time i run this code it works, i press a button to close it again, and then immediately after i run the same code again. The messagebox isnt shown the second time, and my mainwindow now cant be interacted with (like ive opened a modal window). Now i have to close down the application and restart it.

The same thing happens if i set a breakpoint in the application before the window is shown the first time. Nothing is shown and i cant interact with my main window.

The regular System.Window.MessageBox works fine.

And i should mention that the application is a WinForms application with hosted WPF windows and usercontrols.
Mar 30, 2016 at 1:56 PM

I cannot reproduce this in v2.6 and up.
I have a button that when clicked, execute the code to pop the MessageBox. I click a MessageBox button to close it. I then click my button again to re-open the MessageBox, everything is fine.

Can you submit a sample with the problem ?
Mar 31, 2016 at 3:06 PM
I resolved it. It seems to be related to the fact that my main window is winforms and the rest hosted with elementhost. I noticed that it was not just your messagebox that had a problem opening more than once, it was other wpf windows opened from a hosted usercontrol also. The solution HERE solved it.

Basically you need to put the below code for the mainform Load event.
if (System.Windows.Application.Current == null) 
    new System.Windows.Application { ShutdownMode = ShutdownMode.OnExplicitShutdown }; 
And then for the in the ForClosed event