【问题标题】:wpf listbox selecteditem background colour change without changing system brushwpf listbox selecteditem背景颜色更改而不更改系统画笔
【发布时间】:2013-08-01 12:57:39
【问题描述】:

我有一个列表框控件,我想从中删除选择突出显示。我知道最初的直觉是建议覆盖系统突出显示画笔颜色,但不幸的是,这似乎对所有控件都这样做,而且我在 listboxitem 模板中有一个嵌入式组合框,我不希望所选项目对其透明。

有没有办法在不改变系统高亮画笔的情况下改变选中项的高亮颜色?

【问题讨论】:

    标签: wpf listbox


    【解决方案1】:

    将样式直接应用到列表框

    <ListBox  ... >
       <ListBox.ItemContainerStyle>
           <Style TargetType="ListBoxItem">
              <Style.Resources>
                 <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Yellow"/>
              </Style.Resources>
           </Style>                
       </ListBox.ItemContainerStyle>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-17
    • 1970-01-01
    • 1970-01-01
    • 2011-11-24
    • 1970-01-01
    • 2010-12-12
    相关资源
    最近更新 更多