Skip to main content
All docs

TreeViewControl.ChildNodesSelector Property

Gets or sets a selector that returns the list of child nodes for the processed node. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v22.1.dll


public IChildNodesSelector ChildNodesSelector { get; set; }

Property Value

Type Description

The child nodes selector.


The Child Nodes Selector returns node children. You can use this approach to create a hierarchical data structure for different object types.

public class ProjectObject : BaseObject {
    public ObservableCollection<ProjectStage> Stages { get; set; }

public class ProjectStage : BaseObject {
    public ObservableCollection<Task> Tasks { get; set; }

public class Task : BaseObject {
    State state;
    // ...
  1. Create a selector class that implements DevExpress.Xpf.Grid.IChildNodeSelector, and override the SelectChildren method that returns node children.

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

    public class CustomChildrenSelector : IChildNodesSelector {
        public IEnumerable SelectChildren(object item) {
            if (item is Task)
                return null;
            else if (item is ProjectStage)
                return (item as ProjectStage).Tasks;
            else if (item is ProjectObject)
                return (item as ProjectObject).Stages;
            return null;
  2. Assign the Child Nodes Selector to the ChildNodesSelector property.

    <dxg:TreeViewControl ItemsSource="{Binding DataItems}" 
See Also