WPF Always On Top

后端 未结 6 1368
孤街浪徒
孤街浪徒 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:08

    None of the solutions above for me worked, so here is what I ended up doing. It worked perfectly for me.

    Basically, to keep it on top you just set the lose focus event to make it go back to top.

    XAML:

    PreviewLostKeyboardFocus="Window_PreviewLostKeyboardFocus"
        
    

    Code Behind:

    private void Window_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
    {
          var window = (Window)sender;
          window.Topmost = true;
    }
    

提交回复
热议问题