Rakesh Reddy
Rakesh Reddy

Reputation: 71

Borderless application on maximize is hiding behind the task bar in Win 7 and Win 8

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

Answers (2)

Panu Oksala
Panu Oksala

Reputation: 3438

Setting ResizeMode to NoResize helped on my case:

ResizeMode="NoResize"

Upvotes: 0

Henk Holterman
Henk Holterman

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

Related Questions