WPF ListView - how do i set selected item background colour?

前端 未结 2 2067
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 18:50

I currently have this, but it only work for the foreground colour.

Any help would be apriciated :D


    

        
相关标签:
2条回答
  • 2020-12-28 19:19

    It is the Border sub-element of the ListViewItem named "Bd" which handles background painting.

    <Setter TargetName="Bd" Value="Green" Property="Background" />
    
    0 讨论(0)
  • 2020-12-28 19:40

    This will take care of the background color, maybe it will also help you find the solution for the foreground, this is from http://blogs.msdn.com/wpfsdk/archive/2007/08/31/specifying-the-selection-color-content-alignment-and-background-color-for-items-in-a-listbox.aspx

    <Style TargetType="ListBoxItem">
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Green"/>
        </Style.Resources>
    </Style>
    
    0 讨论(0)
提交回复
热议问题