I am migrating my WPF app from .NET Framework to .NET Core 3.0.
Previously I've used the following 'hack' to override the selected unfocused background color for TreeViewItem:
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{x:Static SystemColors.HighlightColor}"/>
</Style.Resources>
</Style>
</TreeView.ItemContainerStyle>
But it doesn't work in .NET Core 3.0: the unfocused selected items still have a light gray background.
The default template in MSDN is using {StaticResource SelectedUnfocusedColor}
for this color so I tried overriding it by putting a desired <Color>
in the Resources section of the TreeView - it didn't help.
I've also tried creating a <Trigger>
in the Style.Triggers for TreeViewItem Style, setting background color to {x:Static SystemColors.HighlightColor}
when IsSelected is True, but it didn't help either.
I'm out of ideas and Google doesn't offer much help (the only other idea I didn't try was to completely retemplate the TreeViewItem which seems a bit of an overkill considering the size of the default template.
SolidColorBrush
resource with anx:Key
ofSystemColors.InactiveSelectionHighlightBrushKey
? – mm8