WPF Always On Top

后端 未结 6 1367
孤街浪徒
孤街浪徒 2020-11-30 00:10

Is it possible to make a window stay always on top even when other application is running on Fullscreen? I\'m using right now TopMost = true but when other appl

6条回答
  •  臣服心动
    2020-11-30 01:02

    I had a main window that I wanted to keep on top of everything (if the user checked "always on top".
    This worked for me. Hope this helps someone.

    // If we want main to stay on top, we set the rest of the menus to Not be top 
    if (mnuViewMainWindowAlwaysOnTopo.IsChecked)
    {
        this.Topmost = true;
        
        foreach (var window in Application.Current.Windows)
            // Don't change for main window
            if (window.GetType().Name != this.GetType().Name)
                window.Topmost = false;
    }
    else this.Topmost = false;
    

提交回复
热议问题