Skip to content

Context Menus

Vetle444 edited this page May 31, 2023 · 8 revisions

A context menu is a pop-up menu that provides shortcuts for actions related to the tapped item.

Inspiration

Usage

A context menu can be attached to any Element. In this example a context menu is attached to a Button with one ContextMenuItem. The ItemClickedCommand is bound to a Command, thus, when any item is tapped, the Command will be executed.

 <dui:Button Text="Open context menu">
    <dui:ContextMenuEffect.Menu>
        <dui:ContextMenu ItemClickedCommand="{Binding ItemClickedCommand}">
            <dui:ContextMenuItem Title="Tap me" />
        </dui:ContextMenu>
    </dui:ContextMenuEffect.Menu> 
</dui:Button>

Modes

There are two context menu-modes:

  • Pressed (default)
  • LongPressed

Pressed

This mode only requires people to tap to show a context menu.

LongPressed

This mode requires people to long-tap the Element to show the context menu. On iOS a "preview" context menu will be used.

Known Limitations

  • Context menus can not be attached to ToolbarItems.

Properties

Inspect the components properties class to further customize and use it.

Clone this wiki locally