Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTreeView.NodeTextTemplate Property

Specifies the common template for the text in the TreeView node labels.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public RenderFragment<ITreeViewNodeInfo> NodeTextTemplate { get; set; }

#Property Value

Type Description
RenderFragment<ITreeViewNodeInfo>

The template content.

#Remarks

The NodeTextTemplate property allows you to specify a template for the text of all TreeView nodes. Use the template’s context parameter to access an ITreeViewNodeInfo object that stores information about a node (text, level, bound data item, and so on).

The following example specifies node label text in the NodeTextTemplate:

<DxTreeView @ref="@treeView"
            Data="@ComponentSets.Data">
    <DataMappings>
        <DxTreeViewDataMapping Children="ComponentSets" />
    </DataMappings>
    <NodeTextTemplate>
        @{
            var dataItem = (ComponentSet)context.DataItem;
        }
        <span>@dataItem.Title</span>
    </NodeTextTemplate>
</DxTreeView>

TreeView NodeTextTemplate

You can also use the NodeTextTemplate to apply custom highlighting to filtered nodes. Refer to our GitHub example for implementation details: Implement Custom Filter.

The NodeTemplate property allows you to modify content for all nodes.

In unbound mode, you can also use the DxTreeViewNode.TextTemplate and DxTreeViewNode.Template properties to apply templates to individual nodes.

Run Demo: TreeView - Templates

See Also