Setting combo box foreground color for the disable

2019-08-29 17:15发布

问题:

I want to change color of combo box for diasbled state to more darker one. Please let me know how do achieve this using triggers or any other way. Thanks !!

回答1:

Change the color in a simple property trigger:

<Style TargetType="ComboBox">
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Foreground" Value="Green"/>
        </Trigger>
    </Style.Triggers>
</Style>


回答2:

Try this:-

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

In my case I set DyanmicResource to SystemColors.GrayTextBrushKey

You can set according to your requirement Check this link out