Skip to main content

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

[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.

<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