I am changing the SystemColors.HighlightBrushKey
and SystemColors.ControlBrushKey
in my ListView and it works well; but this list view contains other complex controls in each of it's ListViewItem (e.g. other ListView, DataGrid) and this new system color gets applied to all the child controls.
<!-- This resource is added to remove the blue highlighting
in the selected ListView item. -->
<SolidColorBrush
x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Transparent" />
<!-- This resource is added to remove the background highlighting
of the inactive selected ListView item. -->
<SolidColorBrush
x:Key="{x:Static SystemColors.ControlBrushKey}"
Color="Transparent" />
Is there a way to reset this system color to original one for a control which is a child of this ListView?
The actual problem I am facing is that these overridden system colors are getting applied to the context menu's of child controls (of ListView); This works fine as such but when Windows Classic theme is used ContextMenus use these system colors and look weird. So I am hoping that if I can reset the SystemColors to original ones, then ContextMenu will work properly.
Is there any other way to solve this problem?
You should override default template of ListViewItem instead of overriding of SystemColors.
Override the template and remove the triggers of selection and mouseOver from it like this:
If want to apply on multiple ListView's, put this resource under
App.Resources
and use wherever needed.