When working with ListView in Xamarin.forms, on selecting an item, the item remains like that with a rather ugly background colour. Can i disable this feature?
Here's my code:
<StackLayout>
<ListView x:Name="FoodList" HasUnevenRows="True" CachingStrategy="RecycleElement" ItemTapped="OnItemTapped">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="0,15,0,0" >
<StackLayout Orientation="Horizontal" BackgroundColor="White" >
<Image Source="{Binding image_url}" Aspect="AspectFill" HeightRequest="200" WidthRequest="200"/>
<StackLayout Orientation="Vertical">
<Label Text="{Binding food_name}" TextColor="Black" Style="{StaticResource MainLisTtext}" />
<Label Text="{Binding price}" TextColor="Black" Style="{StaticResource SubLisTtext}" />
<Label Text="{Binding food_description}" TextColor="Black" Style="{StaticResource SubLisTtext}" />
</StackLayout>
</StackLayout>
</StackLayout>
</ViewCell>vc
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
This can be accomplished by using Custom Renderers
iOS Custom Renderer
Edit the
SelectionStyle
property on iOS.Below is an example that sets the
UITableViewCellSelectionStyle
toNone
.Android Custom Renderer
Create a new drawable,
ViewCellBackground.xml
and save it to theResources
>drawable
folder:Create Custom Renderer for the ViewCell
Edit: Removed implementation without Custom Renderers
Sample Xamarin.Forms ListView App