Skip to main content

DxContextMenu.ItemTextTemplate Property

Specifies the text template for all context menu items.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public RenderFragment<IContextMenuItemInfo> ItemTextTemplate { 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 ItemTextTemplate property to specify a common text template for all menu items. To override a text template for an individual menu item, use the DxContextMenuItem.TextTemplate property.

The following code snippet makes all menu items bold. The last menu item’s text template overrides the common template with the italic formatting attribute:

<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">
    <ItemTextTemplate>
        <b>@context.Text</b>
    </ItemTextTemplate>
    <Items>
        <DxContextMenuItem Text="Home" IconCssClass="oi oi-home" />
        <DxContextMenuItem Text="Contacts" IconCssClass="oi oi-phone" />
        <DxContextMenuItem Text="Calendar" IconCssClass="oi oi-calendar" />
        <DxContextMenuItem Text="About" IconCssClass="oi oi-question-mark" BeginGroup="true">
            <TextTemplate>
                <i>@context.Text</i>
            </TextTemplate>
        </DxContextMenuItem>
    </Items>
</DxContextMenu>

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

Context Menu Items - Text Template

See Also