简体   繁体   中英

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

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM