BackgroundColor of a disabled TextBox

I have a TextBox that is defined through a ControlTemplate. Due to the ControlTemplate, the text field is no longer grayed out if the IsEnabled-false property is set to false.

To provide this functionality, I use the following trigger in the ControlTemplate:

<Trigger Property="IsEnabled" Value="False"> <Setter Property="Foreground" Value="{x:Static SystemColors.GrayTextBrush}" /> </Trigger> 

It works great. However, I must install BackgroundColor as well, but I did not find the corresponding entry in SystemColors . Which entry is the correct entry for the background of disabled controls (TextBoxes)? Is there any other source besides SystemColors?

I do not want to use a fixed value. for example, setting Background="#f4f4f4" , because I'm afraid that in some environments disabled-background has a different meaning, and then my control does not look like it should or even cannot be read (if, for example, the value of GrayTextBrush is next to C # f4).

+7
wpf
source share
2 answers

The following StackOverflow question may help:

Visual Guide to System.Windows.SystemColors

Edit:

I made a few additional checks and looked at the standard XAML styles that Microsoft provides (see Where can I download standard Microsoft WPF themes?. You can determine exactly what SystemColors values SystemColors used for various controls.

For example, here is a snippet of a control pattern for a ComboBox :

 <Trigger Property="IsEnabled" Value="false"> ... <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/> ... </Trigger> 

Microsoft uses SystemColors.ControlBrushKey as the background color for the disabled ComboBox .

+14
source share

The hex value for Win7 aero SystemColors.ControlBrushKey is F0F0F0. Not F4F4F4. So it’s incorrect, I don’t know what to use, so I will use F4F4F4.

0
source share

All Articles