ScaleControl is not called anymore at 100% scaling
See original GitHub issue-
.NET Core Version:
6.0.101 -
Have you experienced this same bug with .NET Framework?:
No
Problem description:
Some Windows Forms controls require manual scaling by overriding the Control.ScaleControl(SizeF, BoundsSpecified) method.
In .NET Framework applications (tested with dpi awareness enabled in manifest, high dpi auto resizing and PerMonitorV2 support enabled in app.config the ScaleControl method is called by the runtime when InitializeComponent calls ResumeLayout regardless of the users screen scaling.
In .NET 6.0 (tested with HighDpiMode.SystemAware and HighDpiMode.PerMonitorV2) the ScaleControl method is not called anymore when the users screen is scaled at 100% (default). My code from .NET Framework relies on ScaleControl being called for all screen scaling in order to initialize graphics in the right resolution.
Expected behavior:
Windows Forms calls ScaleControl at initialization for every control and even 100% scaling like .NET Framework did in order to maintain compatibility.
If this no-op on machines with regular DPI displays is a performance concern, you should mention this breaking change in the migration guides and ideally create a workaround.
Minimal repro:
- Create a new Windows Forms project
dotnet new winforms - Add the following code to
Form1.cs:
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
{
BackColor = Color.Aquamarine;
base.ScaleControl(factor, specified);
}
- Run the application on a device with 100% scaling (96 DPI)
- On .NET Framework you would see a blue window, on .NET 6.0 the window stays gray
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
As a workaround for initialization code which depends on scaling I override
OnLayoutand perform my initialization also there. BecauseOnLayoutis called quite often I check whether initialization has already been done (in my case with a null check). Secondly I check that the scaling factor is one. For all other scaling factor I useScaleControlas usually.The previous implementation for .NET Framework was easier but I accept that it has already been somewhat hacky and there I don’t think it’s necessary to provide an alternative here unless other people ask for it.
I created a custom list view control with an image list and custom sizing logic for the rows. In
ScaleControlI create a new image list with the right scaling from the original and large images. For my custom sizing logic to work, I also save the new row widths which is used later in my resizing logic: View source code