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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…