Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: MessageBox and Application Losing Focus Issue

$
0
0
IC. I think I got it working now. Thanks.

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.

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>