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.Template Property

Specifies the context menu item’s template.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public RenderFragment<IContextMenuItemInfo> Template { 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.

The DxContextMenu.ItemTemplate property specifies the common template for all menu items. The DxContextMenuItem.Template property overrides the common template for the current menu item.

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