Skip to content

PreferredMinMaxWidthHeight APIs don't handle different DPIs well #10452

@niels9001

Description

@niels9001

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);
  1. Press F5
  2. Minimize the window
  3. Use Win+Shift+Arrows to move the window around
  4. 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions