EZShell.Maui 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EZShell.Maui --version 2.0.0
NuGet\Install-Package EZShell.Maui -Version 2.0.0
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="EZShell.Maui" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EZShell.Maui --version 2.0.0
#r "nuget: EZShell.Maui, 2.0.0"
#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 EZShell.Maui as a Cake Addin
#addin nuget:?package=EZShell.Maui&version=2.0.0

// Install EZShell.Maui as a Cake Tool
#tool nuget:?package=EZShell.Maui&version=2.0.0

EZShell.Maui

EZShell.Maui enhances the data transfer experience between ViewModels in Maui applications by leveraging Shell Navigation's powerful capabilities combined with robust Dependency Injection. This integration not only simplifies complex data exchanges but also streamlines the development process, providing a more efficient and seamless navigation framework for developers.

Setup

AppShell.cs

In the constructor of your AppShell.cs class, insert the following line of code after the InitializeComponent() method:

public partial class AppShell : Shell
{
    public AppShell()
    {
        InitializeComponent();
        EzShellNavigation.Initialize(this);
    }
}

MauiProgram.cs

To enable dependency injection, add the following line of code in your MauiProgram.cs class after registering all of your app's services and interfaces:

builder.UseEzShell();

Usage

ViewModels

Ensure your viewmodels inherit from the 'EzShellViewModel' class to enable them to listen for navigation events and handle parameter passing:

using EZShell;

public class SampleViewModel : EZShellViewModel
{
    public SampleViewModel()
    { }
	
    public override Task InitializeAsync(object parameter)
    {
        return base.InitializeAsync(parameter);
    }
	
    public override Task ReverseInitAsync(object parameter)
    {
        return base.ReverseInitAsync(parameter);
    }
}

ContentPage

In your ContentPage .xaml file, specify the ViewModelType and set up listeners for OnAppearing and OnDisappearing events:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:vm="clr-namespace:Sample.ViewModels"
             xmlns:ez="clr-namespace:EzShell.Maui;assembly=EzShell.Maui"
             ez:EzShellPageExtensions.OnAppearingCommand="{Binding OnAppearingCommand}"
             ez:EzShellPageExtensions.OnDisappearingCommand="{Binding OnDisAppearingCommand}"
             ez:EzShellPageExtensions.ViewModelType="{x:Type vm:MainViewModel}"
             x:Class="Sample.ContentPages.MainPage">

</ContentPage>

Utilize EzShell's methods to navigate within your application:

Shell.Current.GoToAsync(nameof(DetailsPage), someData);
Shell.Current.PopAsync(someData);
Shell.Current.PopToRootAsync(someData);
Shell.Current.ChangeTabAsync(1, someData);
Shell.Current.PushMultiStackAsync(myListOfPages, someData);
Shell.Current.PushModalAsync(myContentPage, someData);
Product Compatible and additional computed target framework versions.
.NET net8.0-android34.0 is compatible.  net8.0-ios17.0 is compatible.  net8.0-maccatalyst17.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0-android34.0

    • No dependencies.
  • net8.0-ios17.0

    • No dependencies.
  • net8.0-maccatalyst17.0

    • No dependencies.

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
2.0.4 89 4/11/2024
2.0.3 98 4/8/2024
2.0.2 94 2/14/2024
2.0.0 95 1/27/2024
1.0.1 196 8/5/2022
1.0.0 166 8/5/2022

Simplified usage and optimized the code for latest version of Maui)