Reputation: 71
I have created a borderless window in WPF. I have written a event to maximize the window but on maximizing, part of the window sometimes hides behind the task bar and after a moment appears on top of the task bar.
How can I ensure that the window remains on top of task bar every time ? Following is the way I have implemented:
private void OnMaximizedClicked(object sender, RoutedEventArgs e)
{
this.WindowState = this.WindowState != WindowState.Normal ? WindowState.Normal : WindowState.Maximized;
}
I have tried setting the TopMost property to true, but didn't help me either.
Upvotes: 3
Views: 2396
Reputation: 3438
Setting ResizeMode to NoResize helped on my case:
ResizeMode="NoResize"
Upvotes: 0
Reputation: 273691
This will fix it, but I feel there should be a more elegant way:
this.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow;
this.WindowState = this.WindowState != WindowState.Normal
? WindowState.Normal : WindowState.Maximized;
this.WindowStyle = System.Windows.WindowStyle.None;
Btw, I adapted it from this WinForms answer. So it's not WPF related and you can throw a wider search net.
Upvotes: 1