Windows 10 Creators Update Changes PropertyGrid Control Style

I just upgraded some systems to the Windows 10 Creators Update, and I noticed that the windows PropertyGrid elements changed their default style for the marker headers and fields to dark gray, for example:

<code> PropertyGrid </code> new style

And, as is usually the case with unexpected visual changes, users are not happy. Is there a way to revert to the old standard or maybe override the default style?

+7
windows winforms propertygrid
source share
3 answers

There is an error in the PropertyGrid:

The PropertyGrid.LineColor property has the SystemColors.InactiveBorder . Set the value of SystemColors.InactiveBorder .
But the internal lineColor field lineColor initialized by SystemColors.ControlDark .

This is bad because the Windows Forms designer discovers that the property has the same value as the DefaultValue attribute, and therefore it does not write constructor code for the PropertyGrid.LineColor in InitializeComponent . Thus, at run time, the property is initialized to SystemColors.ControlDark .

As a quick hack, you can set the property after InitializeComponent :

 InitializeComponent(); propertyGrid.LineColor = SystemColors.InactiveBorder; 
+8
source share

We are returning the title color to InactiveBorder in the default Windows theme in the next version of the .NET Framework, which is likely to be included in the Windows 10 Fall Developer Update. The reason this change was introduced was because the foreground and background colors didn't contrast too much in one of the High Contrast themes, so we return to the previously used color only in the default theme. For your reference, the internal work position number, which will also be mentioned in the .Net Framework 4.7.1 release notes, is 407249.

Thank you, Tanya

+3
source share

This seems to be a "feature." Of . .NET Framework 4.7 Release Notes :

The background color of the property grid lines has been changed to provide an 8: 1 contrast ratio for high-contrast themes.

So, I would say no, with the Windows 10 Creators Update, there is no way to revert to the old style without recompiling (see this answer).

I complained here .

Update

I refined the PropertyGrid class as follows:

 sealed class LightPropertyGrid : PropertyGrid { static readonly Color DefaultLineColor = (Color) typeof(PropertyGrid) .GetProperty(nameof(LineColor)) .GetCustomAttribute<DefaultValueAttribute>() .Value; public LightPropertyGrid() { LineColor = DefaultLineColor; } } 

I deduced the initial value for LineColor from the default value defined in the same property. Of course, you can simply assign LineColor = SystemColors.InactiveBorder .

+1
source share

All Articles