问题
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?
回答1:
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>
来源:https://stackoverflow.com/questions/17994753/wpf-listbox-selecteditem-background-colour-change-without-changing-system-brush