开发者

Dialog Window Gets Lost Behind Other Windows

I'm new to WPF so this is probably a pretty easy probl开发者_JAVA技巧em. I open a dialog window using ShowDialog(). Then, if I click into another window that's fullscreen or just covers my dialog, it's difficult to get back to the dialog. The icon that shows up in the taskbar takes me back to the main WPF window but the dialog stays hidden behind the other window. I either have to minimize the blocking window or Alt-Tab back into my application (which will show the dialog but leave the main window hidden).

The definition for the window looks like:

<Window x:Class="MyProject.MyWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        ResizeMode="CanResizeWithGrip"
        ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner"
        Width="750"
        Height="565"
        Title="MyWindow">

I'm opening it like:

var dlg = new MyWindow();
if (dlg.ShowDialog() != true)
    return;


You should set the owner of your dialog window. Something like this.

var dlg = new MyWindow();
dlg.Owner = this;
if (dlg.ShowDialog() != true)    
    return;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜