Home > OS >  How can I add a context menu to UI element in MAUI?
How can I add a context menu to UI element in MAUI?

Time:08-27

The code below is not working, Error XLS0415 The attachable property 'ContextActions' was not found in type 'Grid' and "The type 'FlyoutBase' was not found"

<Grid.ContextActions>
    <MenuItem Text="Test"/>
    <MenuItem Text="Test 2"/>
</Grd.ContextActions>
<FlyoutBase.ContextFlyout>
    <MenuFlyout>
        <MenuFlyoutItem/>
    </MenuFlyout>
</FlyoutBase.ContextFlyout>

CodePudding user response:

The ContextActions can only be used in a ListView cell (see this). This enables a swipe to reveal some buttons on iOS and long press context menu on Android, but only for those cells.

If you want to use this on other elements you can have a look at SwipeView.

For desktop right-clicks we're working on context menus like those right now and they should be ready in .NET 7.

  • Related