Shell | Getting Started
Make .NET MAUI Shell shinier with viewmodel lifecycle management, navigation, and source generation to remove boilerplate, reduce errors, and make your app testable.
Inspired by Prism Library by Dan Siegel and Brian Lagunas.
Features
Section titled “Features”- Navigation service — route-based and ViewModel-based navigation with
INavigator - ViewModel lifecycle — appearing/disappearing, navigation confirmation, navigation awareness, and disposal
- Auto BindingContext — ViewModels automatically attached to page binding contexts
- Source generation — eliminates route registration boilerplate, generates strongly-typed navigation extensions and DI registration
- No special AppShell — works with the default MAUI AppShell, no subclass required
- Testable —
INavigatoris injectable and mockable for unit testing
-
Install the NuGet package
Terminal window dotnet add package Shiny.Maui.Shell -
Configure
UseShinyShellin yourMauiProgram.cspublic static class MauiProgram{public static MauiApp CreateMauiApp(){var builder = MauiApp.CreateBuilder();builder.UseMauiApp<App>().UseShinyShell(x => x.Add<MainPage, MainViewModel>(registerRoute: false).Add<AnotherPage, AnotherViewModel>("another")).ConfigureFonts(fonts =>{fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");});return builder.Build();}} -
Inject
INavigatorinto your ViewModels and navigateusing Shiny;public class MainViewModel(INavigator navigator){public async Task GoToDetails(){await navigator.NavigateTo("another");}}
Quick Example
Section titled “Quick Example”// Navigate by route with argumentsawait navigator.NavigateTo("details", ("Id", 42));
// Navigate by ViewModel with strongly typed setupawait navigator.NavigateTo<DetailViewModel>(vm => vm.Id = 42);
// Go back with argumentsawait navigator.GoBack(("Result", "saved"));AI Coding Assistant
Section titled “AI Coding Assistant”An AI skill is available for Shiny MAUI Shell to help generate pages, ViewModels, navigation, and source-generated routes directly in your IDE.
Claude Code
claude plugin add github:shinyorg/skillsGitHub Copilot — Copy the shiny-maui-shell skill file into your repository’s custom instructions.
Next Steps
Section titled “Next Steps”- Navigation — Full
INavigatorAPI reference - ViewModel Lifecycle — Lifecycle interfaces and events
- Source Generation — Eliminate boilerplate with attributes