Menu
Description
A menu surface composed of clickable items, optional headers, dividers and arbitrarily deep nested submenus. Built on top of the Popover primitive, so positioning, click-outside dismissal and animation are inherited from the shared popover machinery.
Usage
API reference
public sealed class MenuA menu surface composed of clickable items, optional headers, dividers and arbitrarily deep nested submenus. Built on top of the Popover primitive, so positioning, click-outside dismissal and animation are inherited from the shared popover machinery.
Remarks
Menu is the recommended primitive for application menus, dropdown menus and action menus shown in response to a button click or other explicit user gesture. For the classic right-click context menu use the existing ContextMenu component. Submenus open on hover and follow the pointer's intent: a pointer that is heading from a row towards the submenu it opened may cross the rows below it without switching, a pointer that comes to rest on another row switches to that row, and coming back over the row that opened the submenu leaves it exactly as it was. The keyboard walks the same tree - arrows move, ArrowRight and Enter open a submenu, ArrowLeft and Escape close one level - and a menu item's submenu may itself contain items with submenus, and so on. var fileMenu = UI.Menu() .Items( UI.MenuHeader("File"), UI.MenuItem("New", UIcons.Plus).OnClick(() => New()), UI.MenuItem("Open…", UIcons.FolderOpen).OnClick(() => Open()), UI.MenuDivider(), UI.MenuItem("Export").SubMenu( UI.Menu().Items( UI.MenuItem("PDF").OnClick(() => ExportPdf()), UI.MenuItem("CSV").OnClick(() => ExportCsv())))); var trigger = UI.Button("File").OnClick(b => fileMenu.ShowFor(b));
- Namespace
- Tesserae
Constructors
| Name | Description |
|---|---|
| Menu | Creates a new, empty menu. |
Properties
| Name | Description |
|---|---|
| IsVisible | Gets a value indicating whether the menu is currently displayed. |
Methods
| Name | Description |
|---|---|
| Add | Adds a single item to this menu. Most code prefers the params overload Items together with the UI.MenuItem(...) / UI.MenuHeader(...) factory helpers. |
| Items | Adds the given items to this menu, in order. |
| Placement | Sets the preferred placement of this menu relative to its anchor. Defaults to BottomStart, which mirrors the standard dropdown-menu placement of platforms like Windows and macOS. |
| OnHidden | Registers a callback that fires after this menu has been hidden. |
| ShowFor | Shows the menu anchored to the rendered element of anchor. |
| Hide | Hides the menu (and any of its open submenus) if currently visible. |
public Menu Add(Item item)Adds a single item to this menu. Most code prefers the params overload Items together with the UI.MenuItem(...) / UI.MenuHeader(...) factory helpers.
public Menu Placement(TooltipPlacement placement)Sets the preferred placement of this menu relative to its anchor. Defaults to BottomStart, which mirrors the standard dropdown-menu placement of platforms like Windows and macOS.
public Menu OnHidden(Action onHidden)Registers a callback that fires after this menu has been hidden.
| Overload | |
|---|---|
| ShowFor(IComponent) | Shows the menu anchored to the rendered element of anchor. |
| ShowFor(HTMLElement) | Shows the menu anchored to the given DOM element. |