Hello,
Yes, I can reproduce your issue. If you change the selected item color with ViewCell Tapped
event, it will cause reused issue of items
If you want to change selected item to other color. You can use the following way to do it.
For android, you can add these lines to Resources\values\styles.xml
inside the <style>
tag.
<style name="MainTheme" parent="MainTheme.Base">
<item name="android:colorPressedHighlight">@color/ListViewSelected</item>
<item name="android:colorFocusedHighlight">@color/ListViewSelected</item>
<item name="android:colorActivatedHighlight">@color/ListViewSelected</item>
<item name="android:activatedBackgroundIndicator">@color/ListViewSelected</item>
</style>
Then open your Resources\values\colors.xml
, add you want to changed color in it like following code.
<resources>
<color name="launcher_background">#FFFFFF</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<!--set your selected item background color-->
<color name="ListViewSelected">#96BCE3</color>
</resources>
For iOS, you need to create a custom renderer for ViewCell.
[assembly: ExportRenderer(typeof(ViewCell), typeof(MyViewCellRenderer))]
namespace App2.iOS
{
internal class MyViewCellRenderer: ViewCellRenderer
{
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var cell = base.GetCell(item, reusableCell, tv);
cell.SelectedBackgroundView = new UIView
{
//set your selected item background color.
BackgroundColor = UIColor.DarkGray,
};
return cell;
}
}
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.