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 application is running on fullscreen mine becomes invisible. It's WindowStyle = None
window by the way.
Edit: And do not let other window minimalize ofcourse
This won't work 100% of the time, but it will improve the situation somewhat. You can set Topmost = true
in the handler for the Window.Deactivated
event:
private void Window_Deactivated(object sender, EventArgs e)
{
Window window = (Window)sender;
window.Topmost = true;
}
The Deactivated
event will be called whenever your application loses focus (often when another application requests to be Topmost
) and so this will reset your application on top after this.
Try this solution from MSDN, it should work for you.
In the Window Activated Event
add the following code:
this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
this.Topmost = true;
this.Top = 0;
this.Left = 0;
in DeActivated Event
add the following code
this.Topmost = true;
this.Activate();
Original post from MSDN
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With