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

DxContextMenu.Data Property

Specifies a Context Menu component’s data source.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v20.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public IEnumerable Data { get; set; }

Property Value

Type Description
IEnumerable

An IEnumerable object that specifies a data source.

Remarks

The Context Menu component supports binding to hierarchical data structures. A bound Context Menu creates an item for each data item. Use the Data property to bind the Context Menu to a data source.

Note

To bind Context Menu to a hierarchical data structure, specify the Data and ChildrenExpression properties.

<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 menu items.

See Also