tags:

views:

31

answers:

1

hello,

i am new to WPF, and i am trying to open a modal dialog from inside my main window:


public partial class MainWindow : Window
{
    protected void OpenCommandExecuted(object target, ExecutedRoutedEventArgs e)
    {
        DataSearchWindow w = new DataSearchWindow();

        w.Owner = this;
        w.ShowDialog();
    }
    ...
}

and XAML for my DataSearchWindow looks like this:


<Window x:Class="DataSearchWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        ShowInTaskbar='False'
        WindowStartupLocation='CenterOwner'
        WindowStyle='ToolWindow'
        ...>
...
</Window>

Everything works until I press Alt-Tab to switch to another application. When I do that my application disappears from the list shown when Alt-Tab is pressed. It is still in the taskbar and I can return to it using mouse, bu not with Alt-Tab. Has anyone seen this?

konstantin

+2  A: 

This is because of the modal dialog - you cannot Alt-Tab back to the application until the dialog is closed. Since the WindowStyle is set as ToolWindow, it won't show up in Alt-Tab. However, if it were a regular window, the dialog window would show up in Alt-Tab.

Note that this isn't a WPF issue - it is consistent with, for example, a Windows Forms application.

Wonko the Sane
thanks. yes, this is because of the dialog. no, nothing shows up in Alt-Tab popup. When I press Alt-Tab first time, the main window does show up there, but when i press it again, it disappears, no trace of my application whatsoever. RE: consistent: oh, ok, i did not know that. thanks!
akonsu
Yes, this is because your dialog is set as a ToolWindow (didn't notice that the first time through - I'll update my answer). Again, this is consistent with WinForms.
Wonko the Sane
thanks. i removed the ToolWindow style and now it does show up. this will work.
akonsu