I have WPF ListView with GridView view and I want to remove any trace of row highlight.
This useful piece of code can be found in one answer on this site:
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Control.Focusable" Value="False"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
However, while this change helps to remove most of the highlight, it does not remove the horizontal bar that still appears when mouse moves over the ListView row. How do I remove it?
I have dealt with the similar problem involving Button and found a solution that changes Button template by removing its chrome.
In this case of ListView/GridView I am unable to find the corresponding chrome and template to change.
If you have the Windows SDK installed, you can find the XAML source for all default styles (assuming you installed the samples) in:
The zip file contains a folder Core which contains AeroTheme, LunaTheme etc which contain the source for default styles. Unfortunately these files are pretty large (~8500 lines for Aero) and not very well structured or formatted (IMO).
The default control template for a ListViewItem looks like this:
Your best bet for removing all highlighting is probably to replace the ControlTemplate with you own that just includes the GridViewRowPresenter (maybe in a single Border). Don’t forget to include the Trigger that greys the items when the control is disabled.