Borderless window application takes up more space than my screen resolution

code-zoop picture code-zoop · Jan 19, 2010 · Viewed 8.9k times · Source

I have created a borderless application in WPF, and it works pretty good. However, when I set the WindowState to full screen, the application takes up more space than my screen resolution, so there are some pixels outside the screen in all directions! (looks like some hard coded negative margins are added to hide the default border)

Any Ideas how to prevent this from happening?

My xaml:

<Window x:Class="MyApp.Shell"
    WindowStyle="None"
    BorderThickness="0"
    AllowsTransparency="True"
    Background="Transparent"
    ResizeMode="CanResizeWithGrip"
    WindowState="{Binding MainApplicationWindowState}"
    ...

Also, another problem I have seen is that the Windows toolbar / taskbar is covered in the fullsize state, so it looks like the "actual" screen height is used and not the "available" screen height, meaning screen height minus the windows toolbar / taskbar!

Anyone found a solution to these issues?

Thanks

Answer

Aleksandar Toplek picture Aleksandar Toplek · Feb 25, 2013

I found this great solution

<Window WindowStyle="None" WindowStartupLocation="CenterScreen" WindowState="Maximized"
        MaxWidth="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Width}"
        MaxHeight="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Height}"
    >
...
</Window>

But error for me still persists, windows is offset by few pixels on top and left... I tried to set Left and Top to 0 after I change window state but nothing happens.