TextBox.ContextMenuOpening 事件

定义

当系统处理显示上下文菜单的交互时发生。

public:
 virtual event ContextMenuOpeningEventHandler ^ ContextMenuOpening;
// Register
event_token ContextMenuOpening(ContextMenuOpeningEventHandler const& handler) const;

// Revoke with event_token
void ContextMenuOpening(event_token const* cookie) const;

// Revoke with event_revoker
TextBox::ContextMenuOpening_revoker ContextMenuOpening(auto_revoke_t, ContextMenuOpeningEventHandler const& handler) const;
public event ContextMenuOpeningEventHandler ContextMenuOpening;
function onContextMenuOpening(eventArgs) { /* Your code */ }
textBox.addEventListener("contextmenuopening", onContextMenuOpening);
textBox.removeEventListener("contextmenuopening", onContextMenuOpening);
- or -
textBox.oncontextmenuopening = onContextMenuOpening;
Public Custom Event ContextMenuOpening As ContextMenuOpeningEventHandler 
<TextBox ContextMenuOpening="eventhandler" />

事件类型

注解

若要替代上下文菜单或向上下文菜单添加命令,可以处理 ContextMenuOpening 事件,并将默认菜单替换为自定义菜单。 有关此示例,请参阅 自定义 RichEditBox 的 CommandBarFlyout - 在WinUI 2 库中添加“共享”示例。 有关设计信息,请参阅 上下文菜单指南

适用于

另请参阅