【问题标题】:How to bring all windows to front when one of them is brought to front?当其中一个被带到前面时,如何将所有窗户带到前面?
【发布时间】:2015-08-04 06:19:42
【问题描述】:

我所有的窗口共享同一个基类 WindowBase 。 我有

        this.Activated += WindowBase_Activated;

    void WindowBase_Activated(object sender, EventArgs e)
    {
        if (!_bActivating)
        {
            _bActivating = true;
            activateAllWindows();
            Activate();
            _bActivating = false;
        }
    }
    private void activateAllWindows()
    {
        Console.WriteLine("triggered");
        foreach (Window window in Application.Current.Windows)
        {
            if (window.IsVisible && (window as WindowBase)._bActivating == false && window.WindowState==WindowState.Normal)
            {
                window.Activate();
            }
        }
    }

它正在工作,但速度极慢。 但是,当应用程序启动时,我发现“已触发”打印或多或少 100 次。

我要做的就是将所有窗口都放在前面,同时将我从任务栏单击的窗口堆叠到顶部。 我该如何改进?

附:我不会把我的窗户从最小化。就在前面。 我可以在 Qt 中做到这一点,因为 QWidget 有一个名为 stackUnder 的函数(作为窗口)

【问题讨论】:

    标签: wpf window activation


    【解决方案1】:

    好的,我得到了一个技巧。 在我刚刚使用的activeAllWindows中

                    window.Topmost = true;
                    window.Topmost = false;
    

    防止它产生一个激活的事件。

    【讨论】:

      猜你喜欢
      • 2010-09-23
      • 1970-01-01
      • 1970-01-01
      • 2010-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多