Back to Devexpress

TreeListView.ChildNodesSelector Property

wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-8b9d3410.md

latest5.6 KB
Original Source

TreeListView.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.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

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

Property Value

TypeDescription
IChildNodesSelector

The child nodes selector.

|

Remarks

Run Demo: Child Nodes Selector View Example: Use the Child Nodes Selector to Display Hierarchical Data

Use the Child Nodes Selector to create a hierarchical data structure in the TreeListView. An example of this structure is shown below:

csharp
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;
    // ...
}
vb
Public Class ProjectObject
    Inherits BaseObject

    Public Property Stages As ObservableCollection(Of ProjectStage)
End Class

Public Class ProjectStage
    Inherits BaseObject

    Public Property Tasks As ObservableCollection(Of Task)
End Class

Public Class Task
    Inherits BaseObject

    Private state As State
    ' ...
End Class
  1. Create a selector class that implements IChildNodesSelector, and override the SelectChildren(Object) method that returns node children.

  2. Assign the Child Nodes Selector to the ChildNodesSelector property.

  3. Set the TreeListView.TreeDerivationMode property to ChildNodesSelector.

Tip

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

Refer to the following help topic for more information: Bind to Hierarchical Data Structure.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ChildNodesSelector property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/MainWindow.xaml#L52

xml
<dxg:TreeListControl.View>
    <dxg:TreeListView x:Name="view" TreeDerivationMode="ChildNodesSelector" ChildNodesSelector="{StaticResource childrenSelector}" ShowIndicator="False" ShowColumnHeaders="False" AutoWidth="True" AllowPerPixelScrolling="False" CustomColumnDisplayText="view_CustomColumnDisplayText" />
</dxg:TreeListControl.View>

wpf-spreadsheet-pivot-table-api-examples/CS/SpreadsheetWPFPivotTableExamples/MainWindow.xaml#L52

xml
<dxg:TreeListControl.View>
    <dxg:TreeListView x:Name="view" TreeDerivationMode="ChildNodesSelector" ChildNodesSelector="{StaticResource childrenSelector}" ShowIndicator="False" ShowColumnHeaders="False" AutoWidth="True" AllowPerPixelScrolling="False" CustomColumnDisplayText="view_CustomColumnDisplayText" />
</dxg:TreeListControl.View>

wpf-richedit-document-api/CS/DXRichEditControlAPISample/MainWindow.xaml#L57

xml
<dxg:TreeListControl.View>
    <dxg:TreeListView x:Name="view" TreeDerivationMode="ChildNodesSelector" ChildNodesSelector="{StaticResource childrenSelector}" ShowIndicator="False" ShowColumnHeaders="False" AutoWidth="True" AllowPerPixelScrolling="False" CustomColumnDisplayText="view_CustomColumnDisplayText" />
</dxg:TreeListControl.View>

See Also

TreeDerivationMode

Load Nodes Asynchronously Without Locking the Application's UI

TreeListView Class

TreeListView Members

DevExpress.Xpf.Grid Namespace