Properly maximizing WPF window with WindowStyle=None

后端 未结 5 1256
孤街浪徒
孤街浪徒 2020-12-24 14:50

There are two problems with WPF windows when the WindowStyle=None option is used.

  1. The window covers the Taskbar when maximized.
  2. Once maximized, the wi
5条回答
  •  梦谈多话
    2020-12-24 15:47

    I have a nice quick and dirty solution. Try following code when maximize your none bordered window:

    if (WindowState == WindowState.Normal)
    {
          WindowStyle = WindowStyle.SingleBorderWindow;
          WindowState = WindowState.Maximized;
          WindowStyle = WindowStyle.None;
    }
    

    The trick is to set the WindowStyle to SingleBorderWindow then maximize the window and set it back to None.

提交回复
热议问题