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

ItemTemplate vs. HierarchicalDataTemplate in a DiagramModel in XAML

Thread ID:

Created:

Updated:

Platform:

Replies:

95185 Jun 24,2010 03:26 PM UTC Jun 25,2010 12:38 PM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: DiagramWebControl
Tam Bui
Asked On June 24, 2010 03:26 PM UTC

When should I use ItemTemplate and when should I use HierarchicalDataTemplate? In your WPF samples, I see them both being used when dealing with tree layouts. I could not find any further details using the Online Documentation. Thanks for any help.

Jegan R [Syncfusion]
Replied On June 25, 2010 12:38 PM UTC

Hi Tam Bui,

Thanks for your interest in Syncfusion products.

Regarding when to use ItemTemplate and when to use HierarchicalDataTemplate. ItemTemplate is a property name and HierarchicalDataTemplate is the template applied to it the content specified in ItemsSource.

Following is the code snippet is taken form BusinessObjectDataBinding sample.
















Here ItemsSource is a Collection of data which represents hierarchy of data. that is itemsSource has some collection of data, and each of these data again has collection of some other data. When an ItemTemplate is assigned to this kind of source HierarchyDataTemplate is used.

Please go through the CountrySale Object and its sub collections used in this sample.

1)ItemsSource assigned to diagramModel is an observableCollection of Country sale,
2)each CountrySale has a property called “RegionSales” which is a collection of RegionSale,
3)each RegionSale has a property called “Earnings” which is a collection of Sale.

This is what is represented in as ItemsTemplate and HierarchyDataTemplate.

1 & 2)ItemsSource assigned to diagramModel is an observableCollection of CountrySale, and each country sale has collection of RegionSale, which is represented below.

ItemsSource="{Binding Source={StaticResource myList}}"
ItemTemplate="{StaticResource dataTemplate}" >


...


Here Collection of CountrySale(mylist) is the ItemSource for diagramModel, HierarchyDataTemplate is the ItemsTemplate representing that each CountrySale has a collection of RegionSales.

2) each RegionSale has a collection of Sale.






...





Here Collection of Earnings is the ItemSource for RegionSale. HierarchyDataTemplate is the ItemsTemplate representing that, each RegionSales has a collection of Earnings.

As ItemsTemplate and HierarchyDataTemplate are general WPF concepts, they are not explained in the Online documentation, more details on these concepts can be obtained from MSDN library.

DataTemplate : http://msdn.microsoft.com/en-au/library/system.windows.datatemplate.aspx
HierarchyDataTemplate : http://msdn.microsoft.com/en-au/library/system.windows.hierarchicaldatatemplate.aspx

Please let us know if there are any concerns.

Regards,
Jegan

CONFIRMATION

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.

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

;