views:

443

answers:

2

Hello All

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

+2  A: 

I solved the problem this way:

XAML:

WindowStyle="None"
Left="0"
Top="0"
Width="{Binding WPFSettings.Width}"
Height="{Binding WPFSettings.Height}">

Visual Basic:

Public Class WPFSettings
   Public ReadOnly Property Width() As Double
      Get
         Return System.Windows.SystemParameters.PrimaryScreenWidth
      End Get
   End Property

   Public ReadOnly Property Height() As Double
      Get
         Return System.Windows.SystemParameters.PrimaryScreenHeight
      End Get
   End Property
End Class

It works pretty good.

elr
Thanks. Will try it out. One issue I see with the PrimaryScreenHeight is when a second monitor is used, but that should be fairly simple to work around! One note; Since you are using Top and Left, what about Bottom and Right? Will they move even further out of the screen?
code-zoop
Perfect. But for me, it only works if on top of the XAML you posted here, I also set WindowState="Maximized"
Padu Merloti
A: 

In Xaml set the following binding on the Window.MaxHeight:

MaxHeight="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}"

No need for an additional utility class.

Albert Oldfield
But what if I want to use my application on a second monitor?
code-zoop