Back to Devexpress

TreeListView.HasChildNodesPath Property

wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-dee1132c.md

latest4.4 KB
Original Source

TreeListView.HasChildNodesPath Property

Gets or sets a name of a data source’s field that determines whether a node has children. 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 string HasChildNodesPath { get; set; }
vb
Public Property HasChildNodesPath As String

Property Value

TypeDescription
String

The name of a data source’s field that determines whether a node has children.

|

Remarks

Note

A TreeListView with the Self-Referential data structure (TreeDerivationMode is set to Selfreference) ignores the HasChildNodesPath property.

Control Expand Buttons when Sub-level Children are not Fetched

The TreeListView in hierarchical binding mode fetches child nodes of sub-level nodes when you expand their parent node. If the TreeListView.FetchSublevelChildrenOnExpand property is false , all the child nodes display expand buttons (even if they do not have children) after you expand their parent node. The expand button is hidden when you expand a sub-level node that does not contain child nodes:

xaml
<dxg:GridControl Name="treeListView1" ItemsSource="{Binding DataItems}">
    <dxg:GridControl.Columns>
        <dxg:GridColumn FieldName="Name"/>
        <dxg:GridColumn FieldName="Executor"/>
        <dxg:GridColumn FieldName="State"/>
    </dxg:GridControl.Columns>
    <dxg:GridControl.View>
        <dxg:TreeListView TreeDerivationMode="ChildNodesSelector" ChildNodesPath="Tasks" 
                          FetchSublevelChildrenOnExpand="False"/>
    </dxg:GridControl.View>
</dxg:GridControl>

You can make a node display an expand button only if this node has children:

  1. In a data source, create a field that determines whether a node has children (the HasChildNodes field in the code sample below). In this case, the TreeListView will know for which nodes display expand buttons:

  2. Specify the TreeListView.HasChildNodesPath property to this field’s name:

View Example: Control Visibility of Expand Buttons when Sub-level Children are not Fetched

Read Tutorial: Expand and Collapse Nodes

Control whether to Create Child Nodes

You can control whether to create child nodes for a node. The following example shows how to prevent the TreeListView from creating child nodes for the Information Gathering node:

  1. In a data source, create a field that determines whether a node has children (the HasChildNodes field in the code sample below):

  2. Specify the TreeListView.HasChildNodesPath property to this field’s name:

View Example: Control Whether to Create Child Nodes

Read Tutorial: Bind to Hierarchical Data Structure

See Also

Expand and Collapse Nodes

FetchSublevelChildrenOnExpand

ReloadChildNodes

TreeListView Class

TreeListView Members

DevExpress.Xpf.Grid Namespace