PerMonitorV2 DPI scaling not firing ScaleControl method for deeply nested layouts
See original GitHub issue-
.NET Core Version: 6.0 RTM
-
Have you experienced this same bug with .NET Framework?: No
Problem description:
Deeply nested controls don’t get ScaleControl called when moving to secondary monitor (150% DPI -> 100% DPI) in PerMonitorV2 mode.
Expected behavior:
ScaleControl is always called for deeply nested controls when DPI changes.
Minimal repro:
To be done.
It looks like the following code may be to blame: https://github.com/dotnet/winforms/blob/83b3228c2fa5bbde44cb1e8e1b36eb6f328f1289/src/System.Windows.Forms/src/System/Windows/Forms/ContainerControl.cs#L688-L697
When reaching one of the deeply nested container controls it looks up the parent and gets the scale factor from it. However, the parent itself at this point has AutoScaleMode.Inherit and hence the values are not set and the reported scaling is (1.0F, 1.0F). That leads to the following code skipping the scaling:
Values in debugger:

Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (12 by maintainers)

Top Related StackOverflow Question
That method was checking if parent hierarchy has a Container that could lead to scaling children. Given that it was not looking for which parent Container, that should be good.
https://github.com/dotnet/winforms/pull/6130? Seems need to be servicing…