[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Grid View Data Layout
   [Collapse]Binding to Data
     Binding to Data Overview
     Binding to ICollectionView
    [Expand]Server Mode
    [Expand]Binding to any Data Source with Virtual Sources
    [Collapse]TreeListView Data Binding
      Binding to Hierarchical Data Overview
      Binding to Self-Referential Data Structure
      Binding to Hierarchical Data Structure
      TreeList View Unbound Mode
      Dynamic Data Loading
     Applying Data Annotations
     Unbound Columns
     Posting Data to a Connected Database
     Managing Multi-Thread Data Updates
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Filtering and Searching
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Binding to Hierarchical Data Structure

When working with hierarchical data structures, the control's DataControlBase.ItemsSource property contains only data items that correspond to root nodes.

Expanded Using ChildNodesPath

Use the TreeListView.ChildNodesPath to bind the TreeListControl to a collection if all business objects have the same child field. An example of such a structure is shown below.

To bind a collection to the TreeList View, assign the child field name to the TreeListView's TreeListView.ChildNodesPath property and set the TreeListView.TreeDerivationMode property to TreeDerivationMode.ChildNodesSelector. In the example below the Task field is the child field.

Example: How to: Implement ChildNodesPath

Expanded Building a Tree in 'Code Behind'

This approach allows you to create a hierarchical data structure in the TreeView using the TreeListView.ChildNodesSelector property. An example of this structure is shown below:

You should specify the origin of a data object's child item programmatically when using this approach. Create a selector class that implements DevExpress.Xpf.Grid.IChildNodeSelector, and override the SelectChildren method to return the specified node's list of child nodes.

For the Project-Stage-Task business class structure, the selector class is as follows:

Finally, you should assign the Child Nodes Selector to the TreeListView's TreeListView.ChildNodesSelector property and set the TreeListView.TreeDerivationMode property to 'ChildNodesSelector'.


If all business objects have the same 'children' field, assign its name to the TreeListView's TreeListView.ChildNodesPath property. Otherwise, create a Child Nodes Selector.

Example: How to: Implement Hierarchical Data Binding via Child Nodes Selector

Expanded Using Hierarchical Data Templates

Hierarchical Data Templates allows you to create a hierarchical data structure in the TreeView using templates. An example of this structure is shown below:

If all business objects have the same children field/property, create a single template and assign it to the DataRowTemplate property.

Hierarchical data templates can work without a key in your resources. Instead of key, specify the data type it should be applied to:


First, the TreeListView verifies its DataRowTemplateSelector property. If the specified node selector returns null, or the DataRowTemplateSelector property is not specified, it uses a template the DataRowTemplate property specifies If this property is not specified, an implicit hierarchical data template is used.

Once the required HierarchicalDataTemplate is defined for a node, its ItemTemplate and ItemTemplateSelector properties take priority over the corresponding properties the TreeListView (DataRowTemplate and DataRowTemplateSelector) specifies

Use the DataRowTemplateSelector approach if all business objects have different children field/properties:

Create a template selector that implements the System.Windows.Controls.DataTemplateSelector and overrides the SelectTemplate method.

Assign the template selector to the TreeListView's DataRowTemplateSelector property and switch to the HierarchicalDataTemplate tree derivation mode using the TreeListView.TreeDerivationMode property.

Example: How to: Build a Tree via HierarchicalDataTemplate

Expanded Limitations

When a Hierarchical binding mode is used, it is possible to sort and filter by a field value(s) when child's object types are the same. Set the TreeListView.AutoDetectColumnTypeInHierarchicalMode property to True to enable sorting (enabled by default).

Is this topic helpful?​​​​​​​