I've discovered an issue with Show.MessageBox().
In my application, I call Show.Dialog() in several places to display child windows modally.
Then if you use Show.MessageBox() in the new child window, the message box appears centered above the main window of the application. You can put a break point, and the owner of the message box is the main window as well.
To fix it, I did a hack with IQuestionDialog:
[Singleton(typeof(IQuestionDialog))]
public class QuestionDialogViewModel : Caliburn.ShellFramework.Questions.QuestionDialogViewModel
{
public override void AttachView(object view, object context)
{
Window window = view as Window;
if (window != null)
{
Window owner = GetTopWindow();
if (owner != null)
{
window.Owner = owner;
}
}
base.AttachView(view, context);
}
private Window GetTopWindow()
{
//We have to get the next to last window in the list, the MsgBox will be the last
return Application.Current.Windows
.Cast<Window>()
.Reverse()
.Skip(1)
.FirstOrDefault();
}
}
This won't work for all possible cases, but works for my application.
Any cleaner way to fix this?
DefaultWindowManager in latest revision of Caliburn doesn't have this issue.