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

DxContextMenuItem.IconCssClass Property

Specifies a menu item icon’s CSS class.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[DefaultValue(null)]
[Parameter]
public string IconCssClass { get; set; }

#Property Value

Type Default Description
String null

A menu item icon’s CSS class.

#Remarks

DevExpress Blazor components support pre-defined icon sets (such as Iconic or Bootstrap-recommended libraries) and custom icon libraries. Refer to the following topic for more information: Icons.

You can use the IconCssClass property to implement a dynamically visible check sign in the item.

Razor
<DxContextMenu ItemClick="@OnItemClick" >
    <Items>
        <DxContextMenuItem Text="Sort By" IconCssClass="oi oi-sort-ascending">
            <Items>
                <DxContextMenuItem Text="Name" IconCssClass="@GetChecked("Name")" />
                <DxContextMenuItem Text="Size" IconCssClass="@GetChecked("Size")" />
                <DxContextMenuItem Text="Type" IconCssClass="@GetChecked("Type")" />
            </Items>
        </DxContextMenuItem>
        <DxContextMenuItem Text="Copy" IconCssClass="oi oi-action-undo" BeginGroup="true" />
        <DxContextMenuItem Text="Cut" IconCssClass="oi oi-action-redo" />
        <DxContextMenuItem Text="Select All" BeginGroup="true" />
    </Items>
</DxContextMenu>

@code {
    string SortBy { get; set; }

    void OnItemClick(ContextMenuItemClickEventArgs args) {
        if (args.ItemInfo.Text == "Name" || args.ItemInfo.Text == "Size" || args.ItemInfo.Text == "Type")
            SortBy = args.ItemInfo.Text;
    }
    string GetChecked(string ItemText) {
        return (ItemText == SortBy) ? "oi oi-check" : null;
    }
}

ContextMenu Items

Run Demo: Context Menu

See Also