I’m working with .NET MAUI and have implemented a CollectionView in my application. I want to achieve that the selected items in the CollectionView either have no selection color or have a different selection color than orange on the platform Android. In iOS the default value of gray is okay
Is there a way to individually customize or disable the selection color for the items?
Tried setting the VisualStateManager
<ContentPage.Resources>
<Style TargetType="CollectionView">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Red"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ContentPage.Resources>
>Solution :
Did you check the official document about Changing selected item color of CollectionView in the .net maui?
The official document said:
The Style that contains the Selected VisualState must have a TargetType property value that’s the type of the root element of the DataTemplate, which is set as the ItemTemplate property value.
So the TargetType should bethe root element of the DataTemplate in your project such as Grid, StackLayout and so on, not the CollectionView.