Search code examples
c#wpffullscreentaskbarwindow-style

Irregualr behaviour with windows taskbar when making my application 'full screen' (WPF)


I am working on an application that has a full screen mode. When the full screen button/key is pressed the application should take up the entire screen i.e. the windows taskbar also disappears.

this.Window= WindowState.Maximized;
this.Window= WindowStyle.None;
this.Fullscreen = true;

When I first start the application my fullscreen mode works as planned and the windows taskbar disappears. The problem is when I resize the window. After any resizing the full screen mode no longer takes up the entire screen. The windows taskbar is still there. It is not reasonable for me to disable window resizing (although that does solve the problem).

It was my understanding that WindowStyle.None removed the taskbar (it does at first). Does anyone know if resizing the window changes something that stops the WindowStyle.None from doing what it does upon first starting up.

EDIT: I am using a viewbox to scale my content to fullscreen and the stretch of the viewbox in full screen mode is set to Fill


Solution

  • Try applying the WindowStyle first (before WindowState). That fixed it for me.

    Edit: I also noticed that this doesn't work when the window is already maximized. Try this:

    this.WindowState = WindowState.Normal;
    this.WindowStyle = WindowStyle.None;
    this.WindowState = WindowState.Maximized;