0

I have a Listbox control that I want to remove selection highlighting from. I know the initial instinct will be to suggest overriding the system highlight brush colour but unfortunately that seems to do so for all controls, and I have an embedded combobox within the listboxitem template that I do NOT want the selected item to be transparent for.

Is there a way to change the selected item highlight colour without changing the system highlight brush?

NZJames
  • 4,963
  • 15
  • 50
  • 100

1 Answers1

2

Apply the style directly to the ListBox

<ListBox  ... >
   <ListBox.ItemContainerStyle>
       <Style TargetType="ListBoxItem">
          <Style.Resources>
             <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Yellow"/>
          </Style.Resources>
       </Style>                
   </ListBox.ItemContainerStyle>
paparazzo
  • 44,497
  • 23
  • 105
  • 176
  • This no longer works. Current (messier) solution: https://stackoverflow.com/questions/64361138/changing-the-background-of-selecteditem-in-wpf-listbox/64361991#64361991 – J23 Oct 14 '20 at 22:01