Skip to main content
A newer version of this page is available.

DxContextMenu.ChildrenExpression Property

Specifies a lambda expression that returns a menu item’s children.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v20.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public Expression<Func<object, IEnumerable>> ChildrenExpression { get; set; }

Property Value

Type Description
Expression<Func<Object, IEnumerable>>

A lambda expression that returns a menu item’s children.

Remarks

When the Context Menu component is bound to a data source, use the ChildrenExpression property to specify the lambda expression that returns an item’s children.

<DxContextMenu Data="@MenuItems"
               ChildrenExpression="(item => (item as TextFormattingMenuItem).Children)">
</DxContextMenu>

@code {
    List<TextFormattingMenuItem> menuItems;

    abstract class TextFormattingMenuItem {
        protected TextFormattingMenuItem(TextFormatting textFormatting, string text) {
            TextFormatting = textFormatting;
            Text = text;
        }

        public TextFormatting TextFormatting { get; }
        public string Text { get; }
        public List<TextFormattingMenuItem> Children { get; set; }
    }
}

ContextMenu Item Children

Run Demo: Context Menu - Bind to Hierarchical Data

For unbound context menus, use the Items property to specify an item’s children.

See Also