ContextMenuContainer 1.2.3

dotnet add package ContextMenuContainer --version 1.2.3                
NuGet\Install-Package ContextMenuContainer -Version 1.2.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ContextMenuContainer" Version="1.2.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ContextMenuContainer --version 1.2.3                
#r "nuget: ContextMenuContainer, 1.2.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ContextMenuContainer as a Cake Addin
#addin nuget:?package=ContextMenuContainer&version=1.2.3

// Install ContextMenuContainer as a Cake Tool
#tool nuget:?package=ContextMenuContainer&version=1.2.3                

ContextMenuContainer

NuGet Package nuget Paypal

Native context menu for any MAUI and Xamarin.Forms view. Supports Windows, Android, iOS and macOS.

iOS Android macOs Windows
iOS Android Mac UWP

How to use

  1. Add namespace to your XAML file xmlns:apes="http://apes.ge"
  2. Add following line of code to your App.xaml.cs in order to preserve component during linking and resolve our namespace schema in XAML
    APES.UI.XF.ContextMenuContainer.Init();
  1. Extra step for UWP: add our assembly to Xamarin.Forms external assemblies in your UWP App.xaml.cs
    using System.Reflection;
    ...
    var extraAssemblies = new List<Assembly>();
    extraAssemblies.Add(typeof(APES.UI.XF.ContextMenuContainer).GetTypeInfo().Assembly);
    Xamarin.Forms.Forms.Init(e, extraAssemblies);
  1. Wrap your view with ContextMenuContainer, define your context actions inline or bind from your ViewModel
//Inline
<apes:ContextMenuContainer x:Name="ActionsInline">
    <apes:ContextMenuContainer.MenuItems>
        <apes:ContextMenuItem Text="My action" 
                Command="{Binding MyCommand}" 
                CommandParameter="{Binding .}" />
        <apes:ContextMenuItem Text="My destructive action" 
                Command="{Binding MyDestructiveCommand}" 
                CommandParameter="{Binding .}" 
                IsDestructive="True" 
                Icon="{Binding DestructiveIconSource}"/>
    </apes:ContextMenuContainer.MenuItems>
    <apes:ContextMenuContainer.Content>
        <Label Text="Hold me!"/>
    </apes:ContextMenuContainer.Content>
</apes:ContextMenuContainer>
//From binding
<apes:ContextMenuContainer x:Name="ContextActionsWithBinding" 
                            MenuItems="{Binding ImageContextItems}">
    <apes:ContextMenuContainer.Content>
        <Frame>
            <Image Source="{Binding IconSource}"/>
        </Frame>
    </apes:ContextMenuContainer.Content>
</apes:ContextMenuContainer>

Icons

Cross-platform icons are really messy at this point, but you can put your assets to the coresponding folder on each platform and then bind to a FileIconImageSource from your ViewModel. Please refer to the sample folder for example. SVG is preferable.

Known issues

  • Using it in a ViewCell template of ListView might lead to issues with recognizing tap/select events from the list itself, so you might consider using TapGestureRecognizer on the template instead

To-Do

  • Configure build scripts
  • Refactor MAUI initialization
  • Add visibility property
  • Add highlight property
  • Add support for shortcuts
  • Add support of accessability features
  • Add support for submenus and separators
  • Add font icons
  • Cover it all with tests

If this plugin saves you time please consider donating via buttons below, so I can make it even better

Paypal

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios17.2 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst17.2 is compatible.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows10.0.19041 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed.  monoandroid13.0 is compatible. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap10.0.19041 is compatible. 
Xamarin.iOS xamarinios was computed.  xamarinios10 is compatible. 
Xamarin.Mac xamarinmac was computed.  xamarinmac20 is compatible. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.3 657 2/11/2024
1.0.8 1,005 12/9/2021
1.0.7 582 6/14/2021
1.0.6 363 6/10/2021
1.0.5 364 6/7/2021
1.0.3 388 6/2/2021
1.0.2 352 5/26/2021
1.0.1 360 5/9/2021
1.0.0 326 4/26/2021

Added MAUI targets