Context Menu

Display a native context menu, that can be attached to nearly any control.

A common pattern in mobile development is to attach a native menu to a control, that can be opened by tapping or holding the control. This is now an easily achievable and highly customizable feature of Rock Mobile!

Due to limitations on Android, these are more fleshed out on iOS. We didn't want to take the native iOS features away, so some properties may not translate to Android.

Getting Started

To get started, we've introduced three controls:

Menu - The top-level menu, can be nested for submenus.

MenuAction - An action that can be taken from the menu (think of this as a Menu item).

MenuGroup - A group of Actions or Menus. Cannot be nested.

System Icons

These are only really supported on iOS. These are in the form of SF Symbols, and you should be careful to ensure this only gets set on the iOS platform. You can see examples of this below.

Examples

<Border HeightRequest="100" 
        BackgroundColor="white"
        Padding="16">
    
    <Label Text="Example Group Item" 
           StyleClass="title2" 
           VerticalOptions="Center"
           TextColor="Black" />
           
    <Rock:ContextMenu.Menu>
        <DataTemplate>
                <Rock:Menu>
                    <Rock:MenuGroup Title="Group Actions">
                        <Rock:MenuAction Title="Take attendance" 
                                         Command="{Binding PushPage}"   
                                         CommandParameter="d7a2700b-8c24-4ff2-908e-6f9ddcced79f" />
                        <Rock:MenuAction Title="View details" 
                                         Command="{Binding ShowToast}"
                                         CommandParameter="Group details" />
                        <Rock:MenuAction Title="Delete" 
                                         IsDestructive="true"
                                         SystemIcon="{OnPlatform iOS=xmark}" />
                    </Rock:MenuGroup>
                </Rock:Menu>
        </DataTemplate>
    </Rock:ContextMenu.Menu>
</Border>

Last updated

⚙️ Powered by Rock RMS