[WinForms][AnchorLayoutV2] Updating some panels hierarchy breaks the anchored layout
.NET version
.Net 10.0.06
Did it work in .NET Framework?
Works with legacy AnchorLayout.
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Works with legacy AnchorLayout.
Issue description
There is some controls hierarchy, using AnchorLayoutV2. When resizing the window, one of the inner panels is resized incorrectly if replaced by an equivalent panel after the InitializeComponent(). Strangely, it can be fixed by forcing its Anchor property to None, then back to the original value.
(this is shown in the reproducer)
Steps to reproduce
Here is a minimal reproducer. WinFormsAnchorLayoutBug.zip
Verified the issue with latest .NET SDK 11.0.100.Preview.5.26256.117 build, the issue has been fixed that the replaced anchored controls continue to resize correctly with the form as below screenshot.
https://github.com/user-attachments/assets/111b7398-2015-4448-a096-f223d7314b85
Verified this issue in .NET 11 Preview 5 test pass build: .NET SDK 11.0.100-preview.5.26279.113, it was fixed with the same testing result as above.