doxsi
doxsi

Reputation: 1014

Xamarin forms: custom view as a cell

In my project, I need to create a list of feeds, something like:

enter image description here

I think to create a XAML content view, but how can use it as a cell?

Is it a good approach?

Upvotes: 0

Views: 211

Answers (1)

NKR
NKR

Reputation: 2943

I think the best way to go is to choose Data Template Selector. If you use Data Template Selector, You can Choose a DataTemplate (view) at runtime based on the value of a data-bound property. Lets say, In your case, your List view might have 3/4 or any number of different kind of ViewCell. Based on the type of cell you want to display different view cell.

There is a nice tutorial on Xamarin doc, you can read at https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/templates/data-templates/selector

Read this one after that (this is a example for Chat App using ViewCell) https://blog.xamarin.com/customizing-list-view-cells-xamarin-forms-datatemplateselector/

Let me know if you need any specific help after reading that.

Upvotes: 1

Related Questions