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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load items in WPF HierarchyNavigator (Breadcrumb) control in on-demand?

Platform: WPF |
Control: HierarchyNavigator

This article describes how to dynamically load next level items (on-demand loading) in WPF HierarchyNavigator (Breadcrumb) when item is selected.

In this example, files in the system drive are load as next level items in on-demand using the HierarchyNavigatorSelectedItemChanged event.

The following code example demonstrates the same.



    <syncfusion:HierarchyNavigator ItemsSource = "{Binding HierarchyItems}" x:Name="hierarchy" Height="50" Width="500" HierarchyNavigatorSelectedItemChanged="Hierarchy_HierarchyNavigatorSelectedItemChanged">
            <HierarchicalDataTemplate ItemsSource = "{Binding FileItems}" >
                <TextBlock Text="{Binding Content}"/>


In the below code, next level items are added to the collection in HierarchyNavigatorSelectedItemChanged in on-demand.



public partial class MainWindow : Window
    public MainWindow()
    private void Hierarchy_HierarchyNavigatorSelectedItemChanged(object sender, Syncfusion.Windows.Tools.Controls.HierarchyNavigatorSelectedItemChangedEventArgs e)
        if (hierarchy.SelectedItem == null)
        HierarchicalModel selectedItem = hierarchy.SelectedItem as HierarchicalModel;
        string[] dirs = Directory.GetDirectories(selectedItem.Content, "*", SearchOption.TopDirectoryOnly);
        foreach (string dir in dirs)
            selectedItem.FileItems.Add(new HierarchicalModel(dir));



public class HierarchicalModel
    public HierarchicalModel(string content, params HierarchicalModel[] items)
        Content = content;
        fileItems = new ObservableCollection<HierarchicalModel>();
        foreach (var item in items)
    private ObservableCollection<HierarchicalModel> fileItems;
    public ObservableCollection<HierarchicalModel> FileItems
        get { return fileItems; }
            if (fileItems != value)
                fileItems = value;
    public string Content { get; set; }



public class HierarchicalViewModel
    public HierarchicalViewModel()
        hierarchyItems = new ObservableCollection<HierarchicalModel>();
            new HierarchicalModel("My Files",
            new HierarchicalModel("D:\\"),
            new HierarchicalModel("C:\\"))
    private ObservableCollection<HierarchicalModel> hierarchyItems;
    public ObservableCollection<HierarchicalModel> HierarchyItems
        get { return hierarchyItems; }
        set { hierarchyItems = value; }



The output for the above code is shown below:












View sample in GitHub


2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile