WPF ComboBox:禁用时的背景色

时间:2010-03-05 17:56:50

标签: wpf windows combobox colors

我目前在WPF中使用此样式用于我的ComboBox:

    <Style TargetType="ComboBox">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Background" Value="#303030"/>
        <Setter Property="BorderBrush" Value="#000000"/>
    </Style>

如何在禁用ComboBox时更改它以指定背景颜色?

(这是此问题的后续行动:WPF combobox colors

2 个答案:

答案 0 :(得分:2)

<Style TargetType="ComboBox">
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="Background" Value="#303030"/>
    <Setter Property="BorderBrush" Value="#000000"/>
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Background" Value="#101010"/>
        </Trigger>
    </Style.Triggers>
</Style>

答案 1 :(得分:1)

我最终使用此处使用的样式作为基础,这确实允许在禁用时设置背景颜色:

http://msdn.microsoft.com/en-us/library/ms752094%28v=VS.85%29.aspx

相关问题