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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Creating a DataTemplate as external XAML file

Thread ID:





130652 May 23,2017 08:50 PM UTC May 25,2017 04:16 AM UTC Xamarin.Forms 3
Tags: SfListView
Valeriano Simeone
Asked On May 23, 2017 09:14 PM UTC

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

Dinesh Babu Yadav [Syncfusion]
Replied On May 24, 2017 12:22 PM UTC

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 

Valeriano Simeone
Replied On May 24, 2017 02:49 PM UTC

your support is great!

Valeriano Simeone

Dinesh Babu Yadav [Syncfusion]
Replied On May 25, 2017 04:16 AM UTC

Hi Valeriano, 
Thanks for your feedback. 
Dinesh Babu Yadav 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon