All docs
V20.2
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

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.v20.2.dll

Declaration

public IChildNodesSelector ChildNodesSelector { get; set; }
Public Property ChildNodesSelector As IChildNodesSelector

Property Value

Type Description
DevExpress.Xpf.Grid.IChildNodesSelector

The child nodes selector.

Remarks

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}" 
                         TreeViewFieldName="Name">
        <dxg:TreeViewControl.ChildNodesSelector>
            <local:CustomChildrenSelector/>
        </dxg:TreeViewControl.ChildNodesSelector>
    </dxg:TreeViewControl>
    
See Also