HierarchicalDataTemplate Class
Represents a DataTemplate that supports HeaderedItemsControl, such as TreeViewItem or MenuItem.
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.Resources>
<LeagueList x:Key="items" />
<HierarchicalDataTemplate DataType="League" ItemsSource="{Binding Path=Divisions}">
<TextBlock Text="{Binding Path=Name}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="Division" ItemsSource="{Binding Path=Teams}">
<TextBlock Text="{Binding Path=Name}"/>
</HierarchicalDataTemplate>
<DataTemplate DataType="Team">
<TextBlock Text="{Binding Path=Name}"/>
</DataTemplate>
</Grid.Resources>
<TreeView DataContext="{StaticResource items}">
<TreeViewItem ItemsSource="{Binding Leagues}" Header="My Soccer Leagues" />
</TreeView>
</Grid>
http://msdn.microsoft.com/en-us/library/system.windows.hierarchicaldatatemplate.aspx
Inheritance Hierarchy
• HierarchicalDataTemplate
Methods
From FrameworkTemplate
Name | Description |
---|---|
Apply | Applies current template to the element specified |
CanSeal | Indicates if the current instance can be sealed |
FindName | Finds the element associated with the specified name defined within this template |
FindName | Returns an object that has the provided identifying name |
GetAvailableTriggers | Gets template triggers if available |
IsSealed | Indicates if the current instance is sealed |
RegisterName | Registers the provided name into the current namescope |
Seal | Seals the current instance |
UnregisterName | Unregisters the provided name from the current namescope |
UpdateName | Updates previously registered item with new one. This is usefull to refresh Binginds when freezables are cloned |
Properties
From HierarchicalDataTemplate
Name | Description | |
---|---|---|
![]() |
ItemContainerStyle | Gets or sets the Style that is applied to the item container for each child item |
![]() |
ItemTemplate | Gets or sets the DataTemplate to apply to the ItemTemplate property on a generated HeaderedItemsControl (such as a MenuItem or a TreeViewItem), to indicate how to display items from the next level in the data hierarchy |
![]() |
ItemTemplateSelector | Gets or sets the DataTemplateSelector to apply to the ItemTemplateSelector property on a generated HeaderedItemsControl (such as a MenuItem or a TreeViewItem), to indicate how to select a template to display items from the next level in the data hierarchy |
![]() |
ItemsSource | Gets or sets the binding for this data template, which indicates where to find the collection that represents the next level in the data hierarchy |


From DataTemplate
Name | Description | |
---|---|---|
![]() |
DataType | Gets or sets the type for which this DataTemplate is intended |
![]() |
Triggers | Gets a collection of triggers that apply property values or perform actions based on one or more conditions. |


From FrameworkTemplate
Name | Description | |
---|---|---|
![]() |
Resources | Gets or sets the collection of resources that can be used within the scope of this template. |
![]() |
VisualTree | Gets or sets the root node of the template. |


Events
HierarchicalDataTemplate has no events