Table of Contents

Class CoreWebView2ContextMenuItem

Namespace
Microsoft.Web.WebView2.Core
Assembly
Microsoft.Web.WebView2.Core.dll

Represents a context menu item of a context menu displayed by WebView.

public class CoreWebView2ContextMenuItem
Inheritance
CoreWebView2ContextMenuItem
Inherited Members

Properties

Children

Gets the list of children menu items if the kind is Submenu.

public IList<CoreWebView2ContextMenuItem> Children { get; }

Property Value

IList<CoreWebView2ContextMenuItem>

Remarks

If the kind is not Submenu, will return null.

CommandId

Gets the Command ID for the CoreWebView2ContextMenuItem.

public int CommandId { get; }

Property Value

int

Remarks

Use this to report the SelectedCommandId in ContextMenuRequested event.

Icon

Gets the Icon for the CoreWebView2ContextMenuItem in PNG, Bitmap or SVG formats in the form of an IStream.

public Stream Icon { get; }

Property Value

Stream

Remarks

Stream will be rewound to the start of the image data before being read.

IsChecked

Gets or sets the checked property of the CoreWebView2ContextMenuItem.

public bool IsChecked { get; set; }

Property Value

bool

Remarks

Must only be used for custom context menu items that are of kind CheckBox or Radio.

IsEnabled

Gets or sets the enabled property of the CoreWebView2ContextMenuItem. Must only be used in the case of a custom context menu item.

public bool IsEnabled { get; set; }

Property Value

bool

Remarks

The default value for this is true.

Kind

public CoreWebView2ContextMenuItemKind Kind { get; }

Property Value

CoreWebView2ContextMenuItemKind

Label

Gets the localized label for the CoreWebView2ContextMenuItem. Will contain an ampersand for characters to be used as keyboard accelerator.

public string Label { get; }

Property Value

string

Name

Gets the unlocalized name for the CoreWebView2ContextMenuItem.

public string Name { get; }

Property Value

string

Remarks

Use this to distinguish between context menu item types. This will be the English label of the menu item in lower camel case. For example, the "Save as" menu item will be "saveAs". Extension menu items will be "extension", custom menu items will be "custom" and spellcheck items will be "spellCheck". Some example context menu item names are:

  • "saveAs"
  • "copyImage"
  • "openLinkInNewWindow"

ShortcutKeyDescription

Gets the localized keyboard shortcut for this CoreWebView2ContextMenuItem.

public string ShortcutKeyDescription { get; }

Property Value

string

Remarks

It will be the empty string if there is no keyboard shortcut. This is text intended to be displayed to the end user to show the keyboard shortcut. For example this property is Ctrl+Shift+I for the "Inspect" CoreWebView2ContextMenuItem.

Events

CustomItemSelected

CustomItemSelected event is raised when the user selects this CoreWebView2ContextMenuItem.

public event EventHandler<object> CustomItemSelected

Event Type

EventHandler<object>

Remarks

Will only be raised for end developer created context menu items.