Context Menu
Display a native context menu that can be attached to nearly any control.
Last updated
Display a native context menu that can be attached to nearly any control.
Last updated
A popular pattern in mobile development is attaching a native menu to a control that opens with a tap or long press. With Rock Mobile, this is not only easy to implement but also highly customizable!
To get started, we've introduced three controls:
- The top-level menu, can be nested for submenus.
- An action that can be taken from the menu (think of this as a Menu item).
- A group of Action
s or Menu
s. These cannot be nested.
Title
string
A string title to be displayed at the top of the menu.
iOS ✅ Android ❌
Title
string
The title of the action.
Command
ICommand
The command to execute when the action is selected.
CommandParameter
object
The parameter to pass along to the command.
Icon
ImageSource
An image icon to display with the menu action.
SystemIcon
string
The system icon to display with the menu icon. See the System Icons section for more info.
iOS ✅ Android ❌
IsEnabled
bool
Enables or disabled the menu action.
IsVisible
bool
Whether or not the action should currently display.
IsDestructive
bool
Whether or not this is a destructive menu item.
Title
string
The title of the group.
Opens a Context Menu when the Border is held down.
In certain cases, you may want the Context Menu to open instantly without a long-press. For this to work properly, the Menu must be attached to a Button.
The Context Menu can sometimes interfere with a TapGestureRecognizer
or other command triggers. To avoid this, you can use the ClickCommand
and ClickCommandParameter
attached properties. This lets you define both the long-press context menu and tap functionality simultaneously!
These are only really supported on iOS. These are in the form of , and you should be careful to ensure this only gets set on the iOS platform. You can see examples of this below.