IContextMenuItem.Enabled Property
Specifies whether a context menu item is enabled.
Namespace: DevExpress.Blazor.Office
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
Declaration
bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
|
Remarks
The following code snippet changes an item’s availability dynamically:
<DxRichEdit CustomizeContextMenu=OnCustomizeContextMenu />
@code {
Selection selection;
string textToSearch;
async Task OnCustomizeContextMenu(IContextMenuItemCollection items) {
if (selection.Intervals[0].Length > 0) {
var span = await selection.ActiveSubDocument.GetTextSpanAsync(selection.Intervals[0]);
textToSearch = span.Text.Trim();
}
else
textToSearch = null;
var searchItem = items.AddCustomItem(0, "Google Search...", async () => {
var url = $"https://www.google.com/search?q={HttpUtility.UrlEncode(textToSearch)}";
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
});
searchItem.Enabled = !string.IsNullOrEmpty(textToSearch);
searchItem.IconCssClass = "search-icon";
// ...
}
}
Refer to the CustomizeContextMenu event description for more information.
See Also