Forum Xamarin.Forms

ListView with custom cell rendering issue


I implemented a custom view cell for the ListView DataTemplate as described here:

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


Sign In or Register to comment.