Back to Devexpress

Breadcrumb Behavior

windowsforms-120612-common-features-behaviors-breadcrumb-behavior.md

latest3.8 KB
Original Source

Breadcrumb Behavior

  • Jul 07, 2025
  • 3 minutes to read

This Behavior allows you to implement breadcrumb navigation within the TreeList‘s hierarchy. This navigation is provided by a separate BreadCrumbEdit control.

The Breadcrumb Behavior pairs the TreeList and BreadCrumbEdit controls. In this pairing mode, the BreadCrumbEdit automatically populates its contents based on the bound TreeList’s hierarchy. The BreadCrumbEdit control’s selection is then in sync with the TreeList’s focused node.

Demo: Explorer(Virtual Tree) module in the XtraTreeList MainDemo

Create Behavior

  1. Ensure that your form already contains TreeList and BreadCrumbEdit controls.

  2. From the TreeList’s smart tag, select Add Behaviors…. This opens the Behaviors dialog allowing you to add BreadCrumbBehavior.

  3. Set up the created BreadCrumbBehavior by specifying the following settings.

Example

csharp
behaviorManager1.Attach<BreadCrumbBehavior>(treeList1, behavior => {
    behavior.Properties.DisplayMember = "DEPARTMENT";
    behavior.Properties.BreadCrumbControl = breadCrumbEdit1;
});
vb
BehaviorManager1.Attach(Of DevExpress.XtraEditors.BreadCrumbBehavior.BreadCrumbBehavior)(TreeList1, Sub(behavior)
                                                                                                        behavior.Properties.DisplayMember = "DEPARTMENT"
                                                                                                        behavior.Properties.BreadCrumbControl = BreadCrumbEdit1
                                                                                                    End Sub)

Optional Settings and Events

ValueMemberSpecifies the field whose contents are used to initialize BreadCrumbEdit item values (BreadCrumbNode.Value). To ensure correct item identification, item values (if specified) must be unique among sibling nodes. You can also provide unique item values by handling the CustomItemContents event.BreadCrumbEvents.CustomItemContents event

Allows you to customize the display text, image, and other settings of BreadCrumbEdit items. To access this event, create a BreadCrumbBehavior at design time. The designer will generate a BreadCrumbEvents object for the behavior.

csharp
private void breadCrumbEvents1_CustomItemContents(object sender, CustomItemContentsEventArgs e) {
    TreeListNode tlNode = e.Item.Tag as TreeListNode;
        if (tlNode == null)
            return;
// Specify a custom caption for root node items.
        if (tlNode.ParentNode == null)
            e.Item.Caption = "Home";
        else
            e.Item.Caption = tlNode.GetDisplayText("Department");
}
vb
Private Sub breadCrumbEvents1_CustomItemContents(sender As Object, e As CustomItemContentsEventArgs) Handles breadCrumbEvents1.CustomItemContents
    Dim tlNode As TreeListNode = TryCast(e.Item.Tag, TreeListNode)
    If tlNode Is Nothing Then
        Return
    End If
' Specify a custom caption for root node items.
    If tlNode.ParentNode Is Nothing Then
        e.Item.Caption = "Home"
    Else
        e.Item.Caption = tlNode.GetDisplayText("Department")
    End If
End Sub