New to Telerik UI for WPFStart a free 30-day trial

How to Display Hierarchical Data

Updated on Sep 24, 2025

RadPanelBarItem inherits from HeaderedItemsControl therefore it can display hierarchical data, e.g. collections that contain other collections.

The HierarchicalDataTemplate class is designed to be used with HeaderedItemsControl types to display such data. There should be virtually no differences between the usage of HierarchicalDataTemplate in RadPanelBar and other controls.

The following example demonstrates how to create a hierarchical data source and bind a RadPanelBar to it, using a HierarchicalDataTemplate. The ItemsSource property of the HierarchicalDataTemplate specifies the binding that has to be applied to the ItemsSource property of each item. The DataTemplate property specifies the template that has to be applied on each item, while the ItemTemplate is the template applied on its child items.

  1. Create a new class and name it MyViewModel:

    C#
    	public class MyViewModel
    	{
    	    public MyViewModel()
    	    {
    	        this.RelatedItems = new ObservableCollection<object>();
    	    }
    	    public string Title { get; set; }
    	    public DateTime DateCreated { get; set; }
    	    public double Price { get; set; }
    	    public IList<object> RelatedItems { get; set; }
    	}

    The class has four properties:

    • Property Price which is of type double.

    • Property CreatedOn which is of type DateTime.

    • Property Title which is of type string.

    • Property RelatedItems which is a collection of objects. These are the child items. Add a static method to the class which aims to create some mock-up data:

      C#
      	public static IList<object> GenerateItems()
      	{
      	    var result = new ObservableCollection<object>();
      	    foreach (var num in Enumerable.Range(1, 5))
      	    {
      	        var item = new MyViewModel();
      	        item.DateCreated = DateTime.Today.AddDays(-num % 15);
      	        item.Price = num * 100 + Convert.ToDouble(num) / 100;
      	        item.Title = String.Format("Item {0}", num);
      	        for (int i = 0; i < 5; i++)
      	        {
      	            var child = new MyViewModel();
      	            child.DateCreated = DateTime.Today.AddDays(-num % 5 - i);
      	            child.Price = num * 100 + Convert.ToDouble(num + i) / 100;
      	            child.Title = String.Format("Item {0}.{1}", num, i);
      	            item.RelatedItems.Add(child);
      	        }
      	        result.Add(item);
      	    }
      	    return result;
      	}
  2. Declare a HierarchicalDataTemplate

    XAML
    	<Window.Resources>
    	    <DataTemplate x:Key="PanelBarItemTemplate">
    	        <StackPanel>
    	            <TextBlock Text="{Binding Title}"/>
    	            <TextBlock Text="{Binding DateCreated}"/>
    	            <TextBlock Text="{Binding Price}"/>
    	        </StackPanel>
    	    </DataTemplate>
    	
    	    <HierarchicalDataTemplate x:Key="PanelBarHeaderTemplate"
    	               ItemsSource="{Binding RelatedItems}"
    	               ItemTemplate="{StaticResource PanelBarItemTemplate}">
    	        <TextBlock Text="{Binding Title}" />
    	    </HierarchicalDataTemplate>
    	</Window.Resources>
  3. Define the RadPanelBar and set its ItemTemplate property

    XAML
    	<telerik:RadPanelBar x:Name="radPanelBar" Width="200" 
    	               HorizontalAlignment="Center" VerticalAlignment="Top"
    	               ItemTemplate="{StaticResource PanelBarHeaderTemplate}">
    	</telerik:RadPanelBar>
  4. Set the ItemsSource property of the RadPanelBar

    C#
    	this.radPanelBar.ItemsSource = MyViewModel.GenerateItems();

    WPF RadPanelBar Hierarchical Data

Not finding the help you need?
Contact Support