Skip to content
View naveasy's full-sized avatar

Block or report naveasy

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
naveasy/README.md

Naveasy

It it works with:

  • .NET MAUI
  • Microsoft.Extensions.DependencyInjection
  • MAUI NavigatonPage.
  • MAUI FlyoutPage (check the samples to see how it works).

Build

Get Started

  1. Install it from nuget.org Static Badge

  2. Add the following namespace to your MauiProgram.cs:
    using Naveasy;

  3. Call .UseNaveasy() on your AppBuilder and then register your Views with it's corresponding ViewModels the your Service Collection by calling AddTransientForNavigation like described bellow.

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
            
        builder.UseMauiApp<App>()
               .UseNaveasy();

        builder.Services
            .AddTransientForNavigation<LoginPage, LoginPageViewModel>()
            .AddTransientForNavigation<HomePage, HomePageViewModel>()
            .AddTransientForNavigation<ProductsPage, ProductsPageViewModel>()
            .AddTransientForNavigation<DetailsPage, DetailsPageViewModel>();

        return builder.Build();
    }
}
  1. Change your App.xaml.cs to assign a new NavigationPage to the MainPage and then use the NavigationService to navigate to the page you want's to.
public partial class App : Application
{
    public App(INavigationService navigationService)
    {
        InitializeComponent();

        //If you wanna navigate to page wraping it into a MAUI's NavigationPage use the Naveasy's
        //generice interface INavgiationPage<YourPageViewModel> like in the example bellow.
        navigationService.NavigateAsync<INavgiationPage<LoginPageViewModel>>();

        //otherwise use it like this:
        //navigationService.NavigateAsync<LoginPageViewModel>();
    }
}

You can refer to the sample that we have here on this repo to have a more in depth understanding of how you can navigate from one page to another and also how to handle the various page lifecycle events. You can optionaly implement the following handy base class which provides the various page lifecicle events that you would care about:

public class ViewModelBase : BindableBase, IInitialize, IInitializeAsync, INavigatedAware, IDestructible
{
    public virtual void OnInitialize(INavigationParameters parameters)
    {
    }

    public virtual Task OnInitializeAsync(INavigationParameters parameters)
    {
        return Task.CompletedTask;
    }

    public virtual void OnNavigatedFrom(INavigationParameters navigationParameters)
    {
    }

    public virtual void OnNavigatedTo(INavigationParameters navigationParameters)
    {
    }

    public virtual void Destroy()
    {
    }
}

Fell free to contribute.

There's No support for MAUI AppShell until MSFT trully fixes the following issues: dotnet/maui#7354 dotnet/maui#21814 dotnet/maui#21816

This library was inpired on the Dotnet Foundation version of PRISM.

Popular repositories Loading

  1. Naveasy Naveasy Public

    A decent free navigation system for .NET MAUI apps.

    C# 44 7