microsoft / microsoft/microsoft-ui-xaml

PreferredMinMaxWidthHeight APIs don't handle different DPIs well

Open
#10,452 4 comments 4 reactions 0 assignees View on GitHub
area-AppWindow bug
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

When the minimum size is set on a window, using the new APIs shipping with 1.7, and a window gets moved to another screen the window size does not get adjusted.

### Steps to reproduce the bug

My setup:
Screen 1: 1920x1080 (100%)
Screen 2: 2048x1152 (150%)

1. Create a new WinUI app using 1.7-stable
2. Add the following code to `MainWindow.xaml.cs`:

```
OverlappedPresenter presenter = OverlappedPresenter.Create();
presenter.PreferredMinimumWidth = 800;
presenter.PreferredMinimumHeight = 800;
this.AppWindow.SetPresenter(presenter);
```

3. Press F5
4. Minimize the window
5. Use Win+Shift+Arrows to move the window around
6. Window can be resized again on the screen with the larger DPI.

The first window shows the bug. The second window (AI Dev Gallery) uses WinUIEx and is rendering as expected.
![Image](https://github.com/user-attachments/assets/6bf249c8-00d4-422b-bcaa-c8ff497d94b3)

### Expected behavior

The window should render properly. See the second part of the gif above for the expected result (the AI Dev Gallery window)

### Screenshots

_No response_

### NuGet package version

Windows App SDK 1.7.0: 1.7.250310001

### Packaging type

Packaged (MSIX)

### Windows version

Windows 11 version 24H2 (22621, October 2024 Update)

### IDE

Visual Studio 2022-preview

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue from MainWindow.xaml.cs using OverlappedPresenter, PreferredMinimumWidth, PreferredMinimumHeight, and AppWindow.SetPresenter, then move the window between the two screens with Win+Shift+Arrow. Trace how these preferred dimensions behave across the 100% and 150% DPI displays; done means the minimum-sized window adjusts and renders correctly after moving between screens.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.