dotnet / dotnet/wpf

The WindowChrome class needs to be updated & fixed

Open
#3,887 6 comments 11 reactions 0 assignees View on GitHub
.NET Framework Enhancement Requested
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

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: ``

![image](https://user-images.githubusercontent.com/42058942/101418073-e05ccb80-38a1-11eb-8b20-6ddd009e4c74.png)

There are some problems as you can see:
1. The size of all the extended window frames are too small.
2. 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: `` 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:

![image](https://user-images.githubusercontent.com/42058942/101418634-1cdcf700-38a3-11eb-8b47-e33bd0a618a4.png)

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:

![image](https://user-images.githubusercontent.com/42058942/101418836-8fe66d80-38a3-11eb-8e44-bddfd4e5ec10.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.