HierarchicalDataTemplate Class

Represents a DataTemplate that supports HeaderedItemsControl objects, such as TreeViewItem.

Namespace:  System.Windows
Assembly:  System.Windows.Controls (in System.Windows.Controls.dll)

public class HierarchicalDataTemplate : DataTemplate
<sdk:HierarchicalDataTemplate .../>

The HierarchicalDataTemplate type exposes the following members.

Public methodHierarchicalDataTemplateInitializes a new instance of the HierarchicalDataTemplate class.

Public propertyDataTypeGets or sets the type for which this DataTemplate is intended. (Inherited from DataTemplate.)
Public propertyDispatcherGets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertyItemContainerStyleGets or sets the Style that is applied to the item container for each child item.
Public propertyItemsSourceGets or sets the binding that is used to generate content for the next sublevel in the data hierarchy.
Public propertyItemTemplateGets or sets the DataTemplate to apply to the ItemTemplate property on a generated HeaderedItemsControl, such as a TreeViewItem, to indicate how to display items in the next sublevel in the data hierarchy.

Public methodCheckAccessDetermines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodClearValueClears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetAnimationBaseValueReturns any base value established for a Silverlight dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueReturns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Public methodLoadContentCreates the UIElement objects in the DataTemplate. (Inherited from DataTemplate.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodReadLocalValueReturns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSetValueSets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The HierarchicalDataTemplate enables you to set a data template for the current level of hierarchical data, as well as, set the template for the next sublevel with the ItemTemplate property. Use a HierarchicalDataTemplate to display hierarchical data in a control, such as a TreeView.

The following example shows two hierarchical data templates declared as resources.

    <sdk:HierarchicalDataTemplate x:Key="ChildTemplate" >
       <TextBlock FontStyle="Italic" Text="{Binding Path=Title}" />
    <sdk:HierarchicalDataTemplate x:Key="NameTemplate" 
        ItemsSource="{Binding Path=ChildTopics}" 
        ItemTemplate="{StaticResource ChildTemplate}">
        <TextBlock Text="{Binding Path=Title}" FontWeight="Bold" />


Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions