microsoft / microsoft/microsoft-ui-xaml
SetTitleBar does not correctly handles window maximize and restore
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
If I have `SetTitleBar` to a `UIElement` that changes its position after window size changes (eg: window maximize & restore), the title bar area is no longer correct.
### Why is this important?
Confusing behavior.
### Steps to reproduce the bug
1. Use this xaml
```xml
```
2. Use this code
```csharp
public MainWindow()
{
InitializeComponent();
ExtendsContentIntoTitleBar = true;
SetTitleBar(Bar);
}
```
3. Build and run the project. The window is created by default non-maximized. Double click the red `Grid` to maximize it, then try to double click it back.
### Actual behavior
It does not work. The titlebar area is messed up. And you have to use the restore caption button to restore the window.
**However**, after the window restore, the titlebar area is still incorrect, as you can't drag on the red `Grid` to move the window, and you have to resize the window a little bit then it works again.
### Expected behavior
The titlebar area should strictly follow the specified `UIElement` 's size and position.
### Screenshots
_No response_
### NuGet package version
2.2.0
### Windows version
Windows 11 (24H2): Build 26100
### Additional context
_No response_
Contributor guide
Research direction
Start with the XAML and MainWindow constructor in the reproduction, focusing on SetTitleBar(Bar) and the maximize/restore sequence. Verify how the title bar area is updated when the UIElement changes position after a window size change. Done means the red Grid remains the correct draggable title bar area through maximize and restore without an extra resize.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100