Skip to content

[.NET 10][High DPI][Regression]ToolStrip DPI change issue in .NET 10 #14449

@koszeggy

Description

@koszeggy

.NET version

.NET 10.0

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Works in .NET Core 3.0 - .NET 9.0

Issue description

Background: I have a DPI aware project that targets a very wide range of platforms starting with .NET Framework 3.5. Per-monitor DPI awareness is not a trivial task, especially if almost every .NET version changes something that breaks the previous behavior, and I have to provide an unified appearance, no matter what the target is. So far, I managed to harmonize the behavior of the ToolStrip control for the various .NET versions, but .NET 10 introduced a change that I could not work around so far.

Issue Details:
Use the attached project that supports multiple targets. To follow the cases easier, it displays the .NET version and the current DPI. Set the DPI of the primary screen to a higer value (e.g. 150%). If you start the app in any .NET version, you should see something like this:

Image

Starting the app with 150% scaling (144 DPI)

Now change the DPI to 100% (or drag the form to a non-primary display with 100% DPI). On .NET Framework 4.7+ and .NET Core 3.0 - .NET 9.0 you the form rescales itself as follows:

Image

Changing the scaling to 100% (96 DPI) on .NET versions that handle DPI changes correctly

Older framework versions don't handle DPI change automatically, but you can work it around by ticking the check box (now let's ignore that the checkbox visual is not resized, I have a workaround for that, too):

Image

Manual scaling on older frameworks

But on .NET 10.0, something is broken. Whereas other controls are scaled correctly, the auto scaling of ToolStrip does not work like in .NET 9.0:

Image

.NET 10.0: Auto scaling of the ToolStrip does not work correctly

And even if I go for manual scaling, the primary menu items under the drop-down menus have too large height (even though the font is scaled correctly), whereas the submenu items have correct height:

Image

.NET 10: Unlike on old frameworks, manual scaling does not fix the appearance - see the huge menu item heights

The menu item height issue is that I have no workaround for. Or is there a way to opt out of any automatic DPI scaling so I can do everything manually? For the .NET Framework there is the EnableWindowsFormsHighDpiAutoResizing option (among others) in the app.config file, but is there something similar for .NET? To be honest, the small changes in DPI handling from version to version cause much headache in such a multi-target project.

Steps to reproduce

Add a ToolStrip to a Form with drop-down/split buttons and some menu items.
See the attached HighDpiToolstripIssue.zip for a minimal repro project.

  1. Before starting the application, change set a high DPI for the primary display (e.g. 150% as in the screenshots above). If you have multiple monitors, set the DPI of the secondary display to 100%.
  2. Select net10.0-windows as the platform target and start the application
  3. Change the DPI to 100% (or drag the form to the secondary display with 100% DPI). Now you can observe the too big font of the ToolStrip (which is not the case with earlier versions)
  4. Tick the Scale Font Manually checkbox. Now the font size is correct, but if you drop down the menus, you can see that the height of the menu items is still too big.

Metadata

Metadata

Assignees

Labels

💥 regression-releaseRegression from a public releasearea-HDPI-SAIssues related to high DPI SystemAware mode

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions