Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to change the highlight color for selected item in the listview?

$
0
0

I'm working with Xamarin Forms ListView and trying to change the highlight color for selected item because right now for Android version, the highlighted item has black color. I'm using DataTemplate to format the ListViewItem. I tried to use ListViewRenderer class but had no success. Could you please help me with this issue? Thanks in advance.

Here is my code:

public class CustomListViewRenderer: ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.ItemClick += (sender, ev) =>
{
Control.GetChildAt(ev.Position).SetBackgroundColor(Android.Graphics.Color.Beige);
};
}
}
}


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>