Context Menu
A menu that opens at the pointer on right-click, or on long-press on touch screens.
Installation
bash
shellui-native add context-menu
Platforms: MAUI · Avalonia. Also installs icon, element-extensions.
Usage
Basic
MAUI and Avalonia
- MAUI opens the menu on right-click, or on a long press on touch screens.
- Avalonia also opens it with the Menu key or Shift+F10 while focus is inside the trigger, and a right-click while it's open moves it.
- On Avalonia the items are tab stops.
API
ContextMenu
XAML children go to Items on Avalonia.
| Property | Type | Default | Description |
|---|---|---|---|
IsOpen |
bool |
false |
Whether it's open. Two-way bindable. |
| Event | Arguments | Description |
|---|---|---|
IsOpenChanged |
bool |
Opened or closed. |
| Method | Description |
|---|---|
OpenAt(Point? point) |
Opens the menu at a point relative to this view, or below the trigger when null. |
SetOpen(bool value) |
Opens or closes it. |
Toggle() |
Opens it if closed, closes it if open. |
Close() |
Closes it. |
ContextMenuTrigger
No properties of its own.
ContextMenuContent
XAML children go to Items on Avalonia and Children on MAUI.
No properties of its own.
ContextMenuItem
| Property | Type | Default | Description |
|---|---|---|---|
Text |
string |
— | Text shown by the component. |
Icon |
IconName |
None |
Lucide icon from IconName; None for no icon. |
Shortcut |
string |
— | Keyboard hint shown at the end of the row (display only). |
IsDestructive |
bool |
false |
Draws the item in the destructive colour. |
| Event | Arguments | Description |
|---|---|---|
Clicked |
— | Clicked or tapped (or Enter / Space with keyboard focus). |
| Method | Description |
|---|---|
Press() |
Picks the item in code, as a click or Enter/Space would. Avalonia only. |
ContextMenuSeparator
No properties of its own.