WPF ListView in GridView Highlighting a Problem

During the update of the GridView (ListView with a large number of columns), I encountered a problem that I could not change the color of the Highlighted row. I searched the Internet and found out that this could help.

<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" /> 

This solved the problem for some people, but it did not help me. The highlight color was still included in the system by default. Finally, I managed to change the color of the selected row, but the highlight is still visible around the border of the row, and I need to get rid of the selection in the columns.

Here is the code where my approach does not work:

 <ListView > <ListView.Resources> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" /> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" /> </ListView.Resources> <ListView.View> <GridView> <GridViewColumn Header="a"/> <GridViewColumn Header="b"/> </GridView> </ListView.View> <ListViewItem>sth</ListViewItem> <ListViewItem>sthelse</ListViewItem> </ListView> 
+4
source share
1 answer

If I really understand, you want to remove the highlight color. if you want to do it, it's simple. Use this style:

 <Style x:Key="SimpleListViewItem" TargetType="ListViewItem"> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> </Style> 

but to use this style you must use this style for the ItemContainerStyle property.

I hope this solution helps you.

considers Rev

0
source

Source: https://habr.com/ru/post/1305125/


All Articles