Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dialog Window Gets Lost Behind Other Windows

I'm new to WPF so this is probably a pretty easy problem. 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;
like image 864
Jason Avatar asked Jul 08 '11 20:07

Jason


People also ask

How do I move a dialog box that is off screen?

You can do this by pressing Alt+Tab until that window is active or clicking the associated taskbar button. After you've got the window active, Shift+right-click the taskbar button (because just right-clicking will open the app's jumplist instead) and choose the “Move” command from the context menu.

How do you bring a dialog box to the front?

You can bring hidden dialog boxes to the front using the Windows task bar or by pressing Alt-Tab to scroll through open windows and dialog boxes. You can also ensure that dialogs do not go behind the VSA main window by selecting the Keep dialogs on top of Main Window option in the Display Preferences Window tab.

How do I get a dialog box on my screen?

Press ALT + SPACEBAR on the keyboard. Press the M key and tap any ARROW keys. Move the mouse to bring the window into view. Click the left mouse button to cancel the operation.


1 Answers

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

var dlg = new MyWindow();
dlg.Owner = this;
if (dlg.ShowDialog() != true)    
    return;
like image 56
Yiğit Yener Avatar answered Sep 28 '22 09:09

Yiğit Yener