Fix close button misalignment in WindowChrome #698
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #677 partially, though I don't see issue with button size in relation to other Fluent apps. On my 4k laptop the caption buttons look the same as Windows Explorer, for example.
For the gap next to the right of the caption buttons, it seems to be default behavior out of the box when setting a WindowChrome.
NonClientFrameEdges = NonClientFrameEdges.Right
was the minimal way to fix it.https://learn.microsoft.com/en-us/dotnet/api/system.windows.shell.nonclientframeedges?view=windowsdesktop-9.0
Setting any other single value didn't fix. Setting Top alone or with other values didn't work. And you can only set 3 at a time out of the 4. So I set Right, Bottom, and Left. I'm not sure exactly the implication but I will cite what I got from Copilot as justification why I thought might as well let OS manage as many edges as we can:
On a side note, some have used setting NonClientFrameEdges to solve flickering problems that arise from using a WindowChrome. I didn't see any flickering by default with the Gallery or a new project that uses .NET 9 Fluent styles, so maybe you're already handling that but could be useful to prevent those.
dotnet/wpf#1176 (comment)
https://stackoverflow.com/questions/51669632/wpf-windowchrome-causing-flickering-on-resize/54904747#54904747
In DevExpress ThemedWindow (just as an example) they exist, because DevExpress uses a custom WindowChrome instead of the native object:
https://supportcenter.devexpress.com/ticket/details/t1201744/themedwindow-resize-behavior-when-resizing-from-the-left-border
Some complain when setting this it causes erroneous white borders or spacing but I didn't observe any.
Microsoft Reviewers: Open in CodeFlow