IC. I think I got it working now. Thanks.
My code looks pretty much like this now:
Also I presume setting MessageBox.Owner has no effect whatsoever in this case. Not like when ChildWindow is not closed upon closing MessageBox.
I think that what got me confused. I thought setting MessageBox.Owner would automatically (or automagically?) focus back to whatever owner/parent it's set to. But it seems it doesn't in this case. I have to do it manually.
Oh, I'm not aware of WindowContainer. Perhaps I might look into it, but for now your simple suggestion is just working as expected.
Thanks again.
My code looks pretty much like this now:
public class ChildWindow : Window
{
protected override OnClosing(object sender, *EventArgs e)
{
if (this.IsChanged)
{
var result = MessageBox.Show(*);
if (result == MessageBoxResult.Yes)
{
var parent = this.Owner;
if (parent != null)
{
parent.Focus();
}
}
}
}
}
From what I understood, now the focus logic needs to be done manually from the ChildWindow POV. It wasn't needed before, when MessageBox not involved.Also I presume setting MessageBox.Owner has no effect whatsoever in this case. Not like when ChildWindow is not closed upon closing MessageBox.
I think that what got me confused. I thought setting MessageBox.Owner would automatically (or automagically?) focus back to whatever owner/parent it's set to. But it seems it doesn't in this case. I have to do it manually.
Oh, I'm not aware of WindowContainer. Perhaps I might look into it, but for now your simple suggestion is just working as expected.
Thanks again.