We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Creating a DataTemplate as external XAML file

Hi,how can i set ItemTemplate to external XAML file?(without DataTemplateSelector class).thanksValeriano

5 Replies

DB Dinesh Babu Yadav Syncfusion Team May 24, 2017 07:22 AM

Hi Valeriano, 
Thank you for using Syncfusion Products. 
The reported requirement “Defining the ItemTemplate in external XAML file” can be achieved by ResourceDictionary and you can define the template in any file within the ResourceDictionary and access it by key which is defined for each template. Here, we have create the DataTemplate for ItemTemplate in the Resources dictionary of App.xaml file as like below code snippet and bind the Key to the ItemTemplate property in MainPage.xaml. 
Code Example[XAML]: 
      <DataTemplate x:Name="CustomTemplate" x:Key="CustomTemplate"> 
        <Grid x:Name="grid" RowSpacing="1"> 
?xml version="1.0" encoding="utf-8" ?> 
    <local:ContactsViewModel x:Name="viewModel"/> 
      <listView:SfListView x:Name="listView" ItemSize="70"  
                           ItemTemplate="{StaticResource CustomTemplate}" 
                           ItemsSource="{Binding Contactsinfo}"  
For you reference, we have attached the sample and you can download it from the below link. 
Please let us know if you require further assistance. 
Dinesh Babu Yadav 

VS Valeriano Simeone May 24, 2017 09:49 AM

your support is great!

Valeriano Simeone

DB Dinesh Babu Yadav Syncfusion Team May 24, 2017 11:16 PM

Hi Valeriano, 
Thanks for your feedback. 
Dinesh Babu Yadav 

LS Liviu Sosu January 12, 2021 05:15 AM

I have alos found this thread very useafull. Thank you Valeriano for asking and Syncfusion for answering.

LN Lakshmi Natarajan Syncfusion Team January 12, 2021 05:50 AM

Hi Liviu, 
Thank you for your feedback.  
Lakshmi Natarajan 

Live Chat Icon For mobile
Up arrow icon