WPF组合框颜色 [英] WPF combobox colors

查看:158
本文介绍了WPF组合框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中通过将 Style 添加到App.xaml来更改所有 ComboBox

I'm changing the look of all ComboBoxes in my application by adding this Style to App.xaml:

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

有两种颜色,我无法设置:

There are two colors that I haven't been able to set:

1)背景颜色 IsEnabled = false

2)当鼠标位于 ComboBox 上方时,突出显示 Background

2) the highlight Background color when the mouse is over the ComboBox.

如何更改这两种颜色?

推荐答案

您想要检查样式触发器。还需要重写ItemContainerStyle以摆脱默认浅蓝色选择颜色

You want to check Style Triggers . Also need to override the ItemContainerStyle to get rid of the default light blue selection color

<Style.Triggers>
  <Trigger Property="IsMouseOver" Value="true">
    <Setter Property="Background" Value="SomeColor" />
  </Trigger>
  <Trigger Property="IsEnabled" Value="false">
    <Setter Property="Background" Value="SomeOtherColor" />
  </Trigger>
</Style.Triggers>

这篇关于WPF组合框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆