Anchored controls scale incorrectly on multi-monitor setup using HDPI PerMonitorV2
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 1d 13m
- Merged PRs (30d)
- 85
Description
### .NET version
.NET 8.0
### Did it work in .NET Framework?
Not tested/verified
### Did it work in any of the earlier releases of .NET Core or .NET 5+?
On .NET 6 the issue isn't present this severely but present in a different way
### Issue description
When creating a WinForms app targeting .NET 8.0 with an auto-scaleable element anchored to at least two opposing sites on a form (e.g. a button or text box) and the project being set to HDPI mode `PerMonitorV2`, the element will wildly change it's size (up to being completely invisible) when dragged between monitors with different HDPI settings (e.g. one scaled to default 100 %, one to 150 %).
#### Setup



#### .NET 8.0
Loaded on 100 % monitor:

Dragged to 150 % monitor first time:

Dragged back to 100 % monitor first time:

Dragged back to 150 % monitor second time:

Dragged back to 100 % monitor second time:

Dragged back to 150 % monitor third time:
Same as second time.
#### .NET 6
Loaded on 100 % monitor:
Same as in .NET 8.
Dragged to 150 % monitor first time:

Dragged back to 100 % monitor first time:

Dragged to 150 % monitor second time:
Same as first time.
#### PS
I think this issue is different from e.g. #8157 because that one is explicitly about elements in SplitContainers, while mine is about elements directly on forms.
### Steps to reproduce
1. Create a new WinForms project targeting .NET 8.0.
2. Add a button to the form.
3. Drag it bigger so it "anchors" to the edges.
4. Set the "Anchor" property to "Top, Bottom, Left, Right".
5. Start the program on a 100 % scaled monitor.
6. Drag it to a higher scaled (e.g. 150 %) monitor.
7. Drag it back to the 100 % monitor.
Example Project:
[Test.zip](https://github.com/dotnet/winforms/files/14419738/Test.zip)
Contributor guide
Assessment
This issue has not been assessed yet.