PJSouzaSoftware.ContextActions.Maui 0.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package PJSouzaSoftware.ContextActions.Maui --version 0.0.1
                    
NuGet\Install-Package PJSouzaSoftware.ContextActions.Maui -Version 0.0.1
                    
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="PJSouzaSoftware.ContextActions.Maui" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PJSouzaSoftware.ContextActions.Maui" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="PJSouzaSoftware.ContextActions.Maui" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PJSouzaSoftware.ContextActions.Maui --version 0.0.1
                    
#r "nuget: PJSouzaSoftware.ContextActions.Maui, 0.0.1"
                    
#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.
#:package PJSouzaSoftware.ContextActions.Maui@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PJSouzaSoftware.ContextActions.Maui&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=PJSouzaSoftware.ContextActions.Maui&version=0.0.1
                    
Install as a Cake Tool

PJ.ContextActions.Maui

Usage

Note: MacCatalyst is not supported by this library. Supported platforms are Android, iOS, and Windows (via .NET MAUI).

1. Installation

Add the PJ.ContextActions.Maui NuGet package to your .NET MAUI project.

2. Initialization

In your MauiProgram.cs, add .UseContextActions() to the builder:

using PJ.ContextActions.Maui;

public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();
    builder
        .UseMauiApp<App>()
        .ConfigureFonts(fonts =>
        {
            fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
        })
        .UseContextActions();
    // ...
    return builder.Build();
}

3. Usage Example

XAML

Add the pj namespace and use <pj:ContextActions.ContextActions> inside your CollectionView:

<ContentPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:pj="clr-namespace:PJ.ContextActions.Maui;assembly=PJ.ContextActions.Maui">

    <CollectionView x:Name="cv">
        <pj:ContextActions.ContextActions>
            <pj:MenuItem Clicked="MenuItem_Clicked" Text="Primeiro" />
            <pj:MenuItem Command="{Binding ClickCommand}" Text="Segundo" />
        </pj:ContextActions.ContextActions>
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Label Text="{Binding .}" />
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</ContentPage>
Code-behind (C#)

Set up the ItemsSource, Command, and event handler in your page's code-behind:

public partial class MainPage : ContentPage
{
    public Command<object> ClickCommand { get; }

    public MainPage()
    {
        InitializeComponent();
        var list = new List<string>();
        for (var i = 0; i < 100; i++)
            list.Add($"Item {i}");
        cv.ItemsSource = list;

        ClickCommand = new Command<object>((i) =>
        {
            System.Diagnostics.Debug.WriteLine($"Segundo item clicado: {i}");
        });

        BindingContext = this;
    }

    void MenuItem_Clicked(object sender, EventArgs e)
    {
        System.Diagnostics.Debug.WriteLine($"Primeiro item clicado: {sender}");
    }
}

Support

This project is open source and maintained by one person. If you need urgent fixes or custom features, you can support the development through github sponsor.

Product Compatible and additional computed target framework versions.
.NET net9.0-android35.0 is compatible.  net9.0-ios18.0 is compatible.  net9.0-windows10.0.19041 is compatible.  net10.0-android was computed.  net10.0-ios was computed.  net10.0-windows 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
0.3.0 162 8/31/2025
0.2.0 86 8/24/2025
0.0.1 130 8/22/2025