Repository navigation
Description
- .NET Core Version: 3.1.6
- Windows version: (
10.0.19042) - Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
Problem description:
The WindowChrome class that allows us to customize the non-client area of WPF windows has a few bugs. First, the sizes for the window frame are not correct and do not represent the correct default window frame sizes.
In addition, this class has not been updated for Windows 10. Ever since Windows 10, the right, left, and bottom non-client frames are transparent except for a 1px border which is what gives windows their "borderless" look. When using WindowChrome on Windows 10, this is not taken into consideration.
The following XAML code will show the current problems with the WindowChrome class.
XAML: <WindowChrome/>
There are some problems as you can see:
- The size of all the extended window frames are too small.
- On Windows 10, the transparent side non-client frames are not being taken into account.
In order to fix the side border issues on Windows 10, we need to make the XAML the following: <WindowChrome NonClientFrameEdges="Bottom,Left,Right"/> Consider making this the default behavior on Windows 10. However, this fixes only the side border problem, as the titlebar is still too small. Also, even though the side border do look fixed, the amount of non-client border that has been brought back is too little (due to the size of all the extended window frames being too small.) This results in:
We need the correct extended frame sizes fixed first, because it not only messes up the look of the extended window frame borders, but it also will cause problems when an app is maximized, because the too small frame hangs over the monitor, which can result in transparent holes in the app's UI.
Next, it seems like WM_NCMOUSELEAVE is not being handled properly. There are times when the mouse quickly moves over the extended frame's caption buttons then leaves, but the highlight is not removed from the caption button. This picture shows this phenomenon happening on the close button, but it happens on all buttons:



Activity
ClosetBugSlayer commentedon Dec 25, 2020
All of these bugs relate to WindowChrome.
#3675 #2242 #3193 #1176 #1269
AzAgarampur commentedon Dec 25, 2020
Majority of the problems mentioned are because of incorrect nonclient dimensions gathered by
WindowChrome. #1176 is also another longtime bug I wish gets fixed ASAP but I think it has to do more with the DirectX compositor and how it handles the window styles more than a problem with theWindowChromeclass itself.crypto-rsa commentedon Aug 2, 2021
There is also a StackOverflow issue when using a custom
WindowChromein a window withSizeToContentset toWidthAndHeight. Not sure if it would be fixed by any of the mentioned issues.GF-Huang commentedon Nov 7, 2022
Similar issue.
WindowChromehas different appearance on Win11 21H2 and Win11 22H2.In this issue (HandyOrg/HandyControl#1277), although I mentioned the difference in how
hc:WindowandWindowlook on Win11 22H2, but I found that thehc:Windowworks well on Win11 21H2 but incorrect on Win11 22H2.Works well means there is not black border at the top of the app window.
NickeManarin commentedon Mar 17, 2024
Another weird bug, when you have
NonClientFrameEdges="Left"(or any combination withLeftvalue) andUseAeroCaptionButtons="True"and some style setting is changed in Windows Settings (like the accent color), the content of the window will slowly (over the course of 1-2s) shift to the left by ~50px.If you have
Right, the window content may shift back to the correct position.fix(app): ilk acilista maximize padding'i uygula
merge: ilk acilista maximize padding fix'i (dotnet/wpf#3887 kablaji)
SunsetTechuila commentedon Aug 5, 2026
Relevant issue: #11204