How to remove mouse hover effect from ListBox at AvaloniaUI?
Here is my ListBox element:
<ListBox SelectionMode="Multiple" x:Name="FileList" ItemsSource="{Binding FileInfoModels}" Tapped="FileList_OnTapped" DoubleTapped="FileList_OnDoubleTapped">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding FileName}"></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I tryed remove it via ListBox.Styles
<ListBox SelectionMode="Multiple" x:Name="FileList" ItemsSource="{Binding FileInfoModels}" Tapped="FileList_OnTapped" DoubleTapped="FileList_OnDoubleTapped">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding FileName}"></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.Styles>
<Style Selector="ListBoxItem:pointerover">
<Setter Property="Background" Value="Transparent"></Setter>
</Style>
</ListBox.Styles>
</ListBox>
but it still doestn work.
You should try to override the background of a ContentPresenter
in the template instead
<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
<Setter Property="Background" Value="Transparent"/>
</Style>
If you have similar problems you can look for the associated xaml file on Avalonia's github and see how the styles are applied there. Note that you have to find a file that corresponds to your library version and theme, because there are major differences between Avalonia 11 and earlier versions.