Hi Genoveva,
Thank you for using syncfusion support.
#Regarding How to change the DataTemplate depending on Layout.
We have checked your reported query from our end. You can achieve your requirements with the help of DataTemplateSelector. Inside the OnSelectTemplate override method, you can return the DataTemplate according to the SfListView ‘s layout from the container.
Code snippet
|
class MyDataTemplateSelector : Xamarin.Forms.DataTemplateSelector
{
public DataTemplate LinearLayoutDataTemplate { get; set; }
public DataTemplate GridLayoutDataTemplate { get; set; }
public MyDataTemplateSelector()
{
}
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
{
var listView = container as SfListView;
var layoutManager = listView.LayoutManager;
return (layoutManager is LinearLayout) ? this.LinearLayoutDataTemplate : this.GridLayoutDataTemplate;
}
} |
We have attached the tested sample for your reference and you can download the same from the following location.
Please let us know if you have any concern.
Regards,
SaiGanesh Sakthivel