Reputation: 87
I made a WPF app (WindowStyle="None" hence no default windows buttons like exit, maximize, minimize)
It doesn't set the color (in my case, it's black) to the entire frame:
As you can see, there is a bit of white gap. (It's not a margin, I tested for this).
<Window x:Class="FancyGUI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None"
Title="MainWindow" Height="250" Width="340"
Background="Black">
</Window>
Upvotes: 1
Views: 1629
Reputation: 31
I'm noticing that the typical chrome is removed around the window.
I recreated the window with the code you provided and I see this:
Is there a resource file being referenced that may be affecting the window?
Also, you have Live Visual Tree running. Try clicking the middle button and then try clicking on the white bar. If you can select it, you should see it selected in the VS Live Visual Tree window.
Edit... After seeing Jcl's post about the ResizeMode="NoResize" I gave it a try. Sure enough, that's the secret.
Thanks Jcl!
Upvotes: 3
Reputation: 28272
You need ResizeMode="NoResize"
in your window, otherwise there's a title bar shown (empty in your case), even if you set WindowStyle="None"
.
WindowStyle="None"
only:(notice the blue "gap" as you call it on top... that's your white gap, just that my theme is blue)
ResizeMode="NoResize"
:(no gap, but can't resize the window now)
AllowsTransparency="True"
and ResizeMode="CanResizeWithGrip"
:(notice the grip for resizing on bottom right)
Note that having AllowsTransparency=true
may have side effects. If any of those side effects is a problem to you, you can implement the resizing yourself by creating your own (black in your case) border and send the drag/resize messages. Expand on whether you need this or not and I'll show you how.
Upvotes: 3