How to use 2 or more cell types in one tableview?

I have a TableView and depending on type of data I am getting from API i need to use 2 types of cell. One consists of two labels and another cell type is cell with drop down menu. Is it possible to create two different templates for cells in table row and use them?

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    I'm pretty sure you should be able to use a DataTrigger in the XAML to select between to DataTemplates.

  • AsifMayilliAsifMayilli USMember

    @ClintStLaurent well datatemplate is available only in ListView. Are not there anything like that for TableView?

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Is it possible to create two different templates for

    Well... You say you're using a template now. Stands to reason that however you are doing that you should still be able to use a DataTrigger to chose between different choices.

    Whether its a color, bool, visibility... All these can set at runtime via DataTrigger. I would expect you can do something with your templates however they get set. Maybe choose between two properties in your ViewModel: One for each template?

Sign In or Register to comment.