ListView with custom cell rendering issue

Hi,

I implemented a custom view cell for the ListView DataTemplate as described here: https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/viewcell/

It works great, but when I select an item in the ListView, the selected item value in the ViewModel is null.
Before I switched over to the custom cell, I used a default ViewCell, which works great. Selecting a row in the ListView raises an event
and I got the row object in the ViewModel. After many hours of researching I finally found the error:

I used the CachingStrategy "RecycleElement" in the ListView, which causes the selected item to be null after forwarding it to the ViewModel. After setting the
CachingStrategy to the default value "RetainElement", everything works fine. This error only occurrs, if I use a custom cell, with default ViewCells everything works fine.

Maybe this is a bug?!

Best Answer

Answers

Sign In or Register to comment.