New to Telerik UI for WPF? Start a free 30-day trial

ItemTemplate

Updated on Oct 28, 2026

When binding your RadTreeView to a collection, you are able to configure the visualization of the data and the appearance of the RadTreeViewItems via the ItemTemplate and the ItemTemplateSelector properties.

If you want to read about the ItemTemplateSelector, see the main topic ItemTemplateSelector.

This tutorial uses Expression Blend to create a HierarchicalDataTemplate and assign it to the treeview's ItemTemplate property.

The resulting tree displays leagues with their divisions as child items: RadTreeView showing League A and League B, each expanded to display Division A, Division B, and Division C.

  • Create a new Silverlight application and perform the following steps:

    • Add a RadTreeView in your XAML.
    • Create two empty hierarchical data templates and one empty data template in your application resources as it is shown in the XAML below:
    XAML
    <UserControl.Resources>
    
        <DataTemplate x:Key="Team">
            <Grid>
            </Grid>
        </DataTemplate>
    
        <HierarchicalDataTemplate x:Key="Division">
            <Grid>
            </Grid>
        </HierarchicalDataTemplate>
    
        <HierarchicalDataTemplate x:Key="League">
            <Grid>
            </Grid>
        </HierarchicalDataTemplate>
    
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadTreeView x:Name="radTreeView" Margin="8"/>
    </Grid>
  • Open your page in Expression Blend.

    In the Resources window (Window->Resources), in the context of your control you will see the three templates which were declared directly in the XAML on the previous step. Blend Resources pane listing the League, Division, and Team templates.

  • Select Edit resource for the League template. Add an Image and a TextBlock to the template, as shown in the following XAML. League template containing a Grid with Image and TextBlock controls in the Objects and Timeline pane.

    XAML
    <Grid>
        <Grid.Resources>
            <HierarchicalDataTemplate x:Key="League" ItemsSource="{Binding Divisions, Mode=OneWay}"
    				ItemTemplate="{StaticResource Division}">
                <Grid d:DesignWidth="93" d:DesignHeight="26">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.323*"/>
                        <ColumnDefinition Width="0.677*"/>
                    </Grid.ColumnDefinitions>
                    <Image Source="{Binding ImageUrl, Mode=OneWay}"/>
                    <TextBlock Margin="0" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Name, Mode=OneWay}"/>
                </Grid>
            </HierarchicalDataTemplate>

    To configure the binding for the Source property of the Image control, select it in the "Object and Timeline" pane.

    Image selected within the League template in Objects and Timeline.

    Go to the "Properties" pane and find the Source property in the Common properties section. Image Source property in the Common Properties section.

    Open the Source property's options menu and choose Data Binding to open the Create Data Binding dialog. Source property options menu with the Data Binding command.

    In the Create Data Binding dialog, select Explicit Data Context and check Use a custom path expression. Enter ImageUrl to bind the image's Source to that property. Select OK. Image Source binding dialog with ImageUrl entered as the custom path expression.

    Repeat the binding-dialog steps for TextBlock.Text, using the text-binding path in the completed League template below, not ImageUrl.

    Finally, in the "Object and Timeline" pane, select the HierarchicalDataTemplate: HierarchicalDataTemplate selected in Objects and Timeline.

    Find and set the following properties in the "Properties" pane:

    • ItemsSource: Set the binding expression to {Binding Divisions, Mode=OneWay}.

      ItemsSource property with a tooltip showing the one-way binding to Divisions.

    • ItemTemplate: Set the resource reference to {StaticResource Division}.

      ItemTemplate property referencing the Division resource.

    Here is the result XAML for the League data template:

    XAML
    <Grid>
        <Grid.Resources>
            <HierarchicalDataTemplate x:Key="League" ItemsSource="{Binding Divisions, Mode=OneWay}"
    				ItemTemplate="{StaticResource Division}">
                <Grid d:DesignWidth="93" d:DesignHeight="26">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.323"/>
                        <ColumnDefinition Width="0.677"/>
                    </Grid.ColumnDefinitions>
                    <Image Source="{Binding ImageUrl, Mode=OneWay}"/>
                    <TextBlock Margin="0" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Name, Mode=OneWay}"/>
                </Grid>
            </HierarchicalDataTemplate>
  • Perform the same steps for the other two templates - Division and Team.

  • Select the treeview and set its ItemTemplate property to the League resource ({StaticResource League}), as shown in the following XAML. Treeview ItemTemplate property options for selecting a template resource.

XAML
<UserControl>
    <UserControl.Resources>
        <sampleData:RadTreeViewSampleData x:Key="DataSource"/>

        <DataTemplate x:Key="Team">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.323"/>
                    <ColumnDefinition Width="0.677"/>
                </Grid.ColumnDefinitions>
                <Image Source="{Binding ImageUrl, Mode=OneWay}" Width="16" Height="16"/>
                <TextBlock Margin="0" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Name, Mode=OneWay}"/>
            </Grid>
        </DataTemplate>

        <HierarchicalDataTemplate x:Key="Division"
	        ItemsSource="{Binding Teams, Mode=OneWay}"
	        ItemTemplate="{StaticResource Team}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.323"/>
                    <ColumnDefinition Width="0.677"/>
                </Grid.ColumnDefinitions>
                <Image Source="{Binding ImageUrl, Mode=OneWay}" Width="16" Height="16"/>
                <TextBlock Margin="0" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Name, Mode=OneWay}"/>
            </Grid>
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate x:Key="League" 
	        ItemsSource="{Binding Divisions, Mode=OneWay}"
	        ItemTemplate="{StaticResource Division}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.323"/>
                    <ColumnDefinition Width="0.677"/>
                </Grid.ColumnDefinitions>
                <Image Source="{Binding ImageUrl, Mode=OneWay}" Width="16" Height="16"/>
                <TextBlock Margin="0" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Name, Mode=OneWay}"/>
            </Grid>
        </HierarchicalDataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot2" Background="White">
        <telerik:RadTreeView x:Name="radTreeView2" Margin="8"
	       ItemsSource="{Binding Source={StaticResource DataSource}, Path=LeaguesDataSource}"
	       ItemTemplate="{StaticResource League}" />
    </Grid>

The data source class RadTreeViewSampleData assigned to the RadTreeView is covered in greater details in the chapter Binding to Object.

See Also

In this article
See Also
Not finding the help you need?
Contact Support