TrackBar visually breaks with certain changes to certain properties
.NET version
.NET 8
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
.NET 7
Issue description
While working on our app, we noticed there is something wrong with the default Winforms TrackBar control. Recently we updated the app to build with .NET 8 and I created a simple Winforms app to confirm this. There seems to be some visual issue with TrackBar's ticks. I also noticed there is some threshold (percentage of Width to Size/TickFrequency) where it visually breaks. I picked one combination of the properties that is easily reproducible.
I can't reproduce the issue when building the project with .NET 7. The same issue happens when creating the controls programmatically with the specified properties.
Steps to reproduce
- Create a new Winforms App
- Add a TrackBar (from Toolbox) onto the Surface
- Change Width property to 100
- Change Maximum property to 51
- Change TickFrequency property to 10
- Run the App (The TrackBar looks correct while designing, it breaks during runtime)
The issue can reproduce on .NET 8.0 and 9.0 when setting the Maximum property to 51 as below screenshot.
Probably related to #8060
@Zheng-Li01 can you check the PR @elachlan linked and try out the quirk implemented there to opt out of the feature?
@elachlan, @merriemcgaw , yes, after adding the "System.Windows.Forms.TrackBarModernRendering":false in the runtimeconfig.json file, the Trackbar can work well as below screenshot.
Verified this issue on 9.0.100-preview.7.24371.4 with dlls built from winforms repo of main branch, it was fixed: TrackBar's ticks display is normal.
Verified the issue with .NET 9.0.100-preview7.24402.8 test pass build that the issue has been fixed, which have the same results as above.