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

DxContextMenu.ItemTemplate Property

Specifies the template for all context menu items.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public RenderFragment<IContextMenuItemInfo> ItemTemplate { get; set; }

#Property Value

Type Description
RenderFragment<IContextMenuItemInfo>

The template content.

#Remarks

The Context Menu component allows you to define templates for the layout and appearance of menu items and their elements. For more information on templates for context menu items, refer to the following section: Context Menu - Item Templates.

Use the ItemTemplate property to specify a common template for all menu items. To override a template for an individual menu item, use the DxContextMenuItem.Template property.

razor
<div class="target-container" @oncontextmenu="((e) => ContextMenu.ShowAsync(e))" @oncontextmenu:preventDefault>
    <p class="target-caption">RIGHT-CLICK OR LONG PRESS TO SHOW THE CONTEXT MENU</p>
</div>

<DxContextMenu @ref="@ContextMenu">
    <ItemTemplate>
        <b>@context.Text</b> is bold!
    </ItemTemplate>
    <Items>
        <DxContextMenuItem Text="Home" />
        <DxContextMenuItem Text="Contacts" />
        <DxContextMenuItem Text="Calendar" />
        <DxContextMenuItem Text="About" BeginGroup="true">
            <Template>
                <i>@context.Text</i> is italic!
            </Template>
        </DxContextMenuItem>
    </Items>
</DxContextMenu>

@code {
    DxContextMenu ContextMenu { get; set; }
}

Context Menu Items - Template

See Also