Description
.NET version
.NET 10.0 SDK build: 10.0.100-preview.3.25153.9
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No, still repro in .NET 8.0/9.0
Issue description
Current Behavior (.NET Core):
The Custom Colors collection is not cleared after clicking Cancel.
ColorDialogCore.mp4
Expected Behavior (.NET Framework):
The Custom Colors collection reset after clicking Cancel.
ColorDialogFx.mp4
Steps to reproduce
- Create a WinForms project in .NET Core with
Button
andColorDialog
added. - In the button’s click event, show the ColorDialog:
private void button1_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
}
- Run the application and click the button to open the
ColorDialog
. - Add a custom color and click Cancel.
- Click the button again to reopen the
ColorDialog
.
or using following sample app
More Info
- The issue cannot be reproduced when a new ColorDialog is created inside the method each time. In this case, the Custom Colors reset correctly after reopening the dialog in both .NET Core and .NET Framework.
private void button1_Click(object sender, EventArgs e)
{
using (ColorDialog colorDialog = new ColorDialog())
{
colorDialog.ShowDialog();
}
}