How do I change the background of the selected item in the ListBox?

Platform: WPF| Category: ListBox

You can change the colors in your ListBox’s resources, as follows:

[XAML]
<ListBox>
            <ListBox.Resources>
                <SolidColorBrush x:Key='{x:Static SystemColors.HighlightBrushKey}' Color='White'/>
                <SolidColorBrush x:Key='{x:Static SystemColors.HighlightTextBrushKey}' Color='Black'/>
                <SolidColorBrush x:Key='{x:Static SystemColors.ControlBrushKey}' Color='White'/> 
            </ListBox.Resources>
</ListBox>

The 3rd color above is the gray color in which the selected item background is rendered when the listbox does not have the focus.

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.