ShowDialog 使应用程序窗口从 Windows 的 Alt-Tab 列表中消失? [英] ShowDialog makes app window disappear from windows' Alt-Tab list?

查看:27
本文介绍了ShowDialog 使应用程序窗口从 Windows 的 Alt-Tab 列表中消失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 WPF 的新手,我正在尝试从主窗口中打开一个模态对话框:

<预><代码>公共部分类 MainWindow : 窗口{protected void OpenCommandExecuted(object target, ExecutedRoutedEventArgs e){DataSearchWindow w = new DataSearchWindow();w.Owner = 这个;w.ShowDialog();}...}

我的 DataSearchWindow 的 XAML 如下所示:

<预><代码><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='工具窗口'...>...

一切正常,直到我按 Alt-Tab 切换到另一个应用程序.当我这样做时,我的应用程序会从按下 Alt-Tab 时显示的列表中消失.它仍然在任务栏中,我可以使用鼠标返回它,但不能使用 Alt-Tab.有人看过吗?

康斯坦丁

解决方案

这是因为模式对话框 - 在对话框关闭之前,您无法通过 Alt-Tab 返回应用程序.由于 WindowStyle 设置为 ToolWindow,因此它不会显示在 Alt-Tab 中.但是,如果是普通窗口,则对话窗口会显示在 Alt-Tab 中.

请注意,这不是 WPF 问题 - 例如,它与 Windows 窗体应用程序一致.

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

解决方案

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.

这篇关于ShowDialog 使应用程序窗口从 Windows 的 Alt-Tab 列表中消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆