RichEditBox.ContextMenuOpening Event


Occurs when the system processes an interaction that displays a context menu.

 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
RichEditBox::ContextMenuOpening_revoker ContextMenuOpening(auto_revoke_t, ContextMenuOpeningEventHandler const& handler) const;
public event ContextMenuOpeningEventHandler ContextMenuOpening;
function onContextMenuOpening(eventArgs) { /* Your code */ }
richEditBox.addEventListener("contextmenuopening", onContextMenuOpening);
richEditBox.removeEventListener("contextmenuopening", onContextMenuOpening);
- or -
richEditBox.oncontextmenuopening = onContextMenuOpening;
Public Custom Event ContextMenuOpening As ContextMenuOpeningEventHandler 
<RichEditBox ContextMenuOpening="eventhandler" />

Event Type



For more info, design guidance, and code examples, see Rich edit box.

The WinUI 3 Gallery app includes interactive examples of most WinUI 3 controls, features, and functionality. Get the app from the Microsoft Store or get the source code on GitHub.


To override or add commands to the context menu, you can handle the ContextMenuOpening event and replace the default menu with a custom menu. For more info, see Guidelines for context menus

Applies to