ShellInject 3.0.7
See the version list below for details.
dotnet add package ShellInject --version 3.0.7
NuGet\Install-Package ShellInject -Version 3.0.7
<PackageReference Include="ShellInject" Version="3.0.7" />
<PackageVersion Include="ShellInject" Version="3.0.7" />
<PackageReference Include="ShellInject" />
paket add ShellInject --version 3.0.7
#r "nuget: ShellInject, 3.0.7"
#:package ShellInject@3.0.7
#addin nuget:?package=ShellInject&version=3.0.7
#tool nuget:?package=ShellInject&version=3.0.7
ShellInject
ShellInject enhances the data transfer experience between ViewModels in .NET MAUI applications by leveraging Shell Navigation’s powerful features combined with robust Dependency Injection. By simplifying parameter passing, lifecycle management, and ViewModel interactions, ShellInject allows for more efficient and maintainable navigation, especially in applications with complex data flows or multi-page navigation structures.
Setup
MauiProgram.cs
To enable ShellInject and integrate its features into your app, add the following line of code in your MauiProgram.cs file after registering your app’s services and interfaces:
var builder = MauiApp.CreateBuilder();
builder.UseShellInject();
Usage
ViewModels
Ensure your ViewModels inherit from ShellInjectViewModel to handle navigation events and parameter passing. You can override the following methods based on your needs:
DataReceivedAsync(object? parameter)– Triggered when data is passed to the ViewModel.ReverseDataReceivedAsync(object? parameter)– Handles data returned when navigating back from a page.OnAppearing()– Called when the page is about to appear.OnDisappearing()– Called when the page is about to disappear.
ContentPage
In your ContentPage.xaml file, specify the ViewModel to bind by setting the ViewModelType property. This ensures that the correct ViewModel is injected and bound to the page:
xmlns:ez="clr-namespace:ShellInject;assembly=ShellInject"
ez:ShellInjectPageExtensions.ViewModelType="{x:Type vm:MainViewModel}"
Optionally you can set up listeners for OnAppearing and OnDisappearing events
ez:ShellInjectPageExtensions.OnAppearingCommand="{Binding OnAppearingCommand}"
ez:ShellInjectPageExtensions.OnDisappearingCommand="{Binding OnDisAppearingCommand}"
Navigation
ShellInject provides extension methods to simplify navigation between pages and passing parameters between ViewModels:
Example:
await Shell.Current.PushAsync(typeof(DetailsPage), new { id = 123, name = "John" });
Available navigation methods:
Task PushAsync(this Shell shell, Type pageType, object? parameter, bool animate = true)
Task PopAsync(this Shell shell, object? parameter = null, bool animate = true)
Task PopToAsync(this Shell shell, Type pageType, object? parameter = null, bool animate = true)
Task PopToRootAsync(this Shell shell, object? parameter = null, bool animate = true)
Task ChangeTabAsync(this Shell shell, int tabIndex, object? parameter = null, bool popToRootFirst = true)
Task PushMultiStackAsync(this Shell shell, List<Type> pageTypes, object? parameter = null, bool animate = true, bool animateAllPages = false)
Task PushModalAsync(this Shell shell, ContentPage page, object? parameter = null, bool animate = true)
Task ReplaceAsync(this Shell shell, Type? pageType, object? parameter = null, bool animate = true)
Helper methods:
This method looks for the specified Page on the stack and sends the data using the ReverseDataReceivedAsync method.
Task SendDataToPageAsync(this Shell shell, Type? page, object data)
TODO List:
- Update Sample Project
- Add Unit Tests
- Setup CI/CD
- Add Support for Popups
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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-ios18.0 is compatible. net8.0-maccatalyst was computed. net8.0-maccatalyst18.0 is compatible. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- CommunityToolkit.Mvvm (>= 8.4.0)
- Microsoft.Maui.Controls (>= 8.0.100)
-
net8.0-android34.0
- CommunityToolkit.Mvvm (>= 8.4.0)
- Microsoft.Maui.Controls (>= 8.0.100)
-
net8.0-ios18.0
- CommunityToolkit.Mvvm (>= 8.4.0)
- Microsoft.Maui.Controls (>= 8.0.100)
-
net8.0-maccatalyst18.0
- CommunityToolkit.Mvvm (>= 8.4.0)
- Microsoft.Maui.Controls (>= 8.0.100)
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 |
|---|---|---|
| 10.0.1 | 108 | 2/15/2026 |
| 10.0.0 | 208 | 12/22/2025 |
| 9.0.2 | 274 | 9/30/2025 |
| 9.0.1 | 242 | 8/8/2025 |
| 3.1.7 | 838 | 6/21/2025 |
| 3.1.6 | 453 | 4/8/2025 |
| 3.1.5 | 192 | 4/3/2025 |
| 3.1.4 | 191 | 3/20/2025 |
| 3.1.3 | 118 | 3/15/2025 |
| 3.1.2 | 178 | 2/13/2025 |
| 3.1.1 | 169 | 2/5/2025 |
| 3.1.0 | 177 | 2/3/2025 |
| 3.0.11 | 170 | 1/31/2025 |
| 3.0.10 | 150 | 1/29/2025 |
| 3.0.9 | 138 | 1/27/2025 |
| 3.0.8 | 140 | 1/27/2025 |
| 3.0.7 | 150 | 1/27/2025 |
| 3.0.6 | 138 | 1/23/2025 |
| 3.0.5 | 138 | 1/17/2025 |
| 3.0.4 | 487 | 11/1/2024 |
Some minor changes for showing modals with and withouth a navigation page