Reputation: 63
I noticed when setting a windows Height and Width (or Min/MaxHeight and Min/MaxWidth in that regard) to a specific value like 800x450 that the window itself can be smaller then the set values. The only time those values are actually accurate is when setting the WindowStyle
to None
.
MainWindow:
SecondWindow (Light Blue one in the Background)
What causes the the window to be smaller than intended? Also is it always a difference of 7px in Height and 14px in Width?
Upvotes: 1
Views: 967
Reputation: 3556
It is the gap between old, traditional window bounds (location and size) and "extended frame bounds". The latter is actually visible window bounds and can be obtained by DwmGetWindowAttribute function with DWMWA_EXTENDED_FRAME_BOUNDS. These two bounds match, in the case of WPF, when WindowStyle=None
and AllowsTransparency=True
.
As far as I know, the thickness of gap is 7px (left, right, bottom) when monitor DPI is 96 (default, 100%) and increases as monitor DPI increases. You can find a number of tips to deal with this gap by searching the above keywords.
Upvotes: 2