Skip to main content

DxContextMenuItem.TextTemplate Property

Specifies the text template for the context menu item.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public RenderFragment<IContextMenuItemInfo> TextTemplate { 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.ItemTextTemplate property specifies the common text template for all menu items. The DxContextMenuItem.TextTemplate property overrides the common text template for the current menu item.

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