DxContextMenu.NameExpression Property

OBSOLETE

This property is obsolete now. Add the DataMappings tag to markup, define a collection of DxContextMenuDataMapping items, and map item properties to data source fields instead.

Specifies an expression that returns a menu item’s name.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

Declaration

[Browsable(false)]
[Obsolete("This property is obsolete now. Add the DataMappings tag to markup, define a collection of DxContextMenuDataMapping items, and map item properties to data source fields instead.")]
[Parameter]
public Expression<Func<object, string>> NameExpression { get; set; }

Property Value

Type Description
Expression<Func<Object, String>>

A lambda expression that returns an item’s unique identifier (name).

Remarks

When the Context Menu component is bound to a data source, use the NameExpression property to specify lambda expression that returns a menu item’s name.

<DxContextMenu Data="@MenuItems"
               NameExpression="(item => (item as TextFormattingMenuItem).Name)">
</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 string Name { get; set; }
    }
}

Run Demo: Context Menu - Data Binding

For unbound context menus, use the Name property to specify an item’s name.

See Also