You are viewing help content for pre-release software. This document and the features it describes are subject to change. Switch to the current version.

TreeListControl Class

The TreeList control.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.2.dll

Declaration

public class TreeListControl :
    TreeListControlBase
Public Class TreeListControl
    Inherits TreeListControlBase

Related API Members

The following members accept/return TreeListControl objects:

Remarks

The WPF TreeList is a TreeView-Grid multi-purpose data-aware control that can display information as a TREE, a GRID, or a combination of both - in either data bound or unbound mode.

TIP

If you want to display only single-column data, you can use the TreeViewControl.

The TreeListControl inherits the majority of features exposed by the WPF Grid. This includes: data editing, automatic and custom sorting and filtering, full end-user customization options, editable unbound columns and DevExpress Expression editor, built-in validation, automatic and manual summary calculation, UI virtualization and per-pixel scrolling, template and style support, UI localization, extendable context menus, design-time support and much more...

TreeListView

The TreeListControl uses the same View-based data presentation approach introduced by the WPF GridControl. It presents the most widely used method of presenting data - TreeListView. This view supports multi-column display of hierarchical data, data shaping and layout customization features such as Sorting and Filtering, Data Editing via Embedded Cell Editors, Column Auto Width, Column Reordering and Resizing, Fixed Columns, Field Chooser Window and Extendable Context Menus.

To bind the TreeListControl to a data source, use the DataControlBase.ItemsSource property.

Concepts

  • Hierarchical Data Presentation

    The information is displayed in a TREE from hierarchical data structures.

  • Unbound Data Binding Mode

    You can manually create a Tree in XAML or code. Nodes can be represented by objects of different types. The only requirement is that these data objects should have common fields (columns).

  • Tree-Traversal API

    To simplify managing hierarchical data (without writing additional recursive code), the WPF DXTreeList ships with an easy to use API, so you can sequentially visit nodes starting from a specified node down to the last node.

Examples

This example shows how to create a self referencing data structure and display it within the TreeListControl.

View Example

<Window 

    xmlns:dxt="http://schemas.devexpress.com/winfx/2008/xaml/grid"    
        x:Class="TreeList_DataBinding.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxt:TreeListControl Name="treeList">
            <dxt:TreeListControl.Columns>
                <dxt:TreeListColumn FieldName="Name" Header="Employee Name" />
                <dxt:TreeListColumn FieldName="Position" />
                <dxt:TreeListColumn FieldName="Department" />
            </dxt:TreeListControl.Columns>
            <dxt:TreeListControl.View>
                <dxt:TreeListView Name="treeListView1" AutoWidth="True"
                                  KeyFieldName="ID" ParentFieldName="ParentID" />
            </dxt:TreeListControl.View>
        </dxt:TreeListControl>
    </Grid>
</Window>
using System.Windows;

namespace TreeList_DataBinding {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
            treeList.ItemsSource = Stuff.GetStuff();
            treeListView1.ExpandAllNodes();
        }
    }
}
using System;
using System.Collections.Generic;

namespace TreeList_DataBinding {

    public class Employee {
        public int ID { get; set; }
        public int ParentID { get; set; }
        public string Name { get; set; }
        public string Position { get; set; }
        public string Department { get; set; }
    }

    public static class Stuff {
        public static List<Employee> GetStuff() {
            List<Employee> stuff = new List<Employee>();
            stuff.Add(new Employee() { ID = 1, ParentID = 0, Name = "Gregory S. Price", Department = "", Position = "President" });
            stuff.Add(new Employee() { ID = 2, ParentID = 1, Name = "Irma R. Marshall", Department = "Marketing", Position = "Vice President" });
            stuff.Add(new Employee() { ID = 3, ParentID = 1, Name = "John C. Powell", Department = "Operations", Position = "Vice President" });
            stuff.Add(new Employee() { ID = 4, ParentID = 1, Name = "Christian P. Laclair", Department = "Production", Position = "Vice President" });
            stuff.Add(new Employee() { ID = 5, ParentID = 1, Name = "Karen J. Kelly", Department = "Finance", Position = "Vice President" });

            stuff.Add(new Employee() { ID = 6, ParentID = 2, Name = "Brian C. Cowling", Department = "Marketing", Position = "Manager" });
            stuff.Add(new Employee() { ID = 7, ParentID = 2, Name = "Thomas C. Dawson", Department = "Marketing", Position = "Manager" });
            stuff.Add(new Employee() { ID = 8, ParentID = 2, Name = "Angel M. Wilson", Department = "Marketing", Position = "Manager" });
            stuff.Add(new Employee() { ID = 9, ParentID = 2, Name = "Bryan R. Henderson", Department = "Marketing", Position = "Manager" });

            stuff.Add(new Employee() { ID = 10, ParentID = 3, Name = "Harold S. Brandes", Department = "Operations", Position = "Manager" });
            stuff.Add(new Employee() { ID = 11, ParentID = 3, Name = "Michael S. Blevins", Department = "Operations", Position = "Manager" });
            stuff.Add(new Employee() { ID = 12, ParentID = 3, Name = "Jan K. Sisk", Department = "Operations", Position = "Manager" });
            stuff.Add(new Employee() { ID = 13, ParentID = 3, Name = "Sidney L. Holder", Department = "Operations", Position = "Manager" });

            stuff.Add(new Employee() { ID = 14, ParentID = 4, Name = "James L. Kelsey", Department = "Production", Position = "Manager" });
            stuff.Add(new Employee() { ID = 15, ParentID = 4, Name = "Howard M. Carpenter", Department = "Production", Position = "Manager" });
            stuff.Add(new Employee() { ID = 16, ParentID = 4, Name = "Jennifer T. Tapia", Department = "Production", Position = "Manager" });

            stuff.Add(new Employee() { ID = 17, ParentID = 5, Name = "Judith P. Underhill", Department = "Finance", Position = "Manager" });
            stuff.Add(new Employee() { ID = 18, ParentID = 5, Name = "Russell E. Belton", Department = "Finance", Position = "Manager" });
            return stuff;
        }
    }
}
See Also