SimpleToolkit.SimpleShell
4.1.3
dotnet add package SimpleToolkit.SimpleShell --version 4.1.3
NuGet\Install-Package SimpleToolkit.SimpleShell -Version 4.1.3
<PackageReference Include="SimpleToolkit.SimpleShell" Version="4.1.3" />
paket add SimpleToolkit.SimpleShell --version 4.1.3
#r "nuget: SimpleToolkit.SimpleShell, 4.1.3"
// Install SimpleToolkit.SimpleShell as a Cake Addin #addin nuget:?package=SimpleToolkit.SimpleShell&version=4.1.3 // Install SimpleToolkit.SimpleShell as a Cake Tool #tool nuget:?package=SimpleToolkit.SimpleShell&version=4.1.3
SimpleToolkit.SimpleShell
The SimpleToolkit.SimpleShell package provides you with a simplified implementation of .NET MAUI Shell
that lets you easily create a custom navigation experience in your .NET MAUI applications. Same as .NET MAUI Shell
, SimpleShell
provides you with:
- A single place to describe the logical hierarchy of an app.
- A URI-based navigation scheme that permits navigation to any page in the app.
SimpleShell
does not come with any navigation controls. SimpleShell
just gives you the ability to use custom navigation controls along with the URI-based navigation and automatic navigation stack management.
Getting Started
In order to use SimpleToolkit.SimpleShell, you need to call the UseSimpleShell()
extension method in your MauiProgram.cs
file:
builder.UseSimpleShell();
This method also takes a boolean parameter usePlatformTransitions
, which defaults to true
and controls wheter platform-specific animated transitions between pages are used.
XAML namespace
All SimpleShell
related controls and attached properties can be found in the following XAML namespace:
xmlns:simpleShell="clr-namespace:SimpleToolkit.SimpleShell;assembly=SimpleToolkit.SimpleShell"
SimpleShell
SimpleShell
is a simplified implementation of .NET MAUI Shell
. All SimpleShell
is is just a set of containers for your application content with the ability to put the hosting area for pages wherever you want. This gives you the flexibility to add custom tab bars, navigation bars, flyouts, etc. to your Shell
application while using the URI-based navigation.
Let's say we have four root pages - YellowPage
, GreenPage
, RedPage
and BluePage
- and one detail page - YellowDetailPage
. Shell with a simple app bar and tab bar can be defined like this:
<simpleShell:SimpleShell
x:Class="SimpleToolkit.SimpleShellSample.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:simpleShell="clr-namespace:SimpleToolkit.SimpleShell;assembly=SimpleToolkit.SimpleShell"
xmlns:pages="clr-namespace:SimpleToolkit.SimpleShellSample.Views.Pages"
x:Name="thisShell"
Background="White">
<Tab
Title="Yellow-Green"
Route="YellowGreenTab">
<ShellContent
Title="Yellow"
ContentTemplate="{DataTemplate pages:YellowPage}"
Route="YellowPage"/>
<ShellContent
Title="Green"
ContentTemplate="{DataTemplate pages:GreenPage}"
Route="GreenPage"/>
</Tab>
<ShellContent
Title="Red"
ContentTemplate="{DataTemplate pages:RedPage}"
Route="RedPage"/>
<ShellContent
Title="Blue"
ContentTemplate="{DataTemplate pages:BluePage}"
Route="BluePage"/>
<simpleShell:SimpleShell.RootPageContainer>
<Grid
RowDefinitions="*, 50">
<simpleShell:SimpleNavigationHost/>
<HorizontalStackLayout
x:Name="tabBar"
Grid.Row="1"
Margin="20,5"
HorizontalOptions="Center" Spacing="10"
BindableLayout.ItemsSource="{Binding ShellContents, Source={x:Reference thisShell}}">
<BindableLayout.ItemTemplate>
<DataTemplate
x:DataType="BaseShellItem">
<Button
Clicked="ShellItemButtonClicked"
Background="Black"
Text="{Binding Title}"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</HorizontalStackLayout>
</Grid>
</simpleShell:SimpleShell.RootPageContainer>
<simpleShell:SimpleShell.Content>
<Grid
RowDefinitions="50, *">
<Button
x:Name="backButton"
Clicked="BackButtonClicked"
Text="Back"
Margin="20,5"
HorizontalOptions="Start"
Background="Black"/>
<Label
Margin="20,5"
HorizontalOptions="Center" VerticalOptions="Center"
Text="{Binding CurrentShellContent.Title, Source={x:Reference thisShell}}"
FontAttributes="Bold" FontSize="18"/>
<simpleShell:SimpleNavigationHost
Grid.Row="1"/>
</Grid>
</simpleShell:SimpleShell.Content>
</simpleShell:SimpleShell>
As you can see, the logical hierarchy is defined using ShellContent
, Tab
, TabBar
and FlyoutItem
elements as in the original .NET MAUI Shell
. However, visual structure is defined manually using the Content
or RootPageContainer
property. The hosting area for pages is represented by the SimpleNavigationHost
view.
The code behind of the XAML sample above:
public partial class AppShell : SimpleToolkit.SimpleShell.SimpleShell
{
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute(nameof(YellowDetailPage), typeof(YellowDetailPage));
}
private async void ShellItemButtonClicked(object sender, EventArgs e)
{
var button = sender as Button;
var shellItem = button.BindingContext as BaseShellItem;
// Navigate to a new tab if it is not the current tab
if (!CurrentState.Location.OriginalString.Contains(shellItem.Route))
await GoToAsync($"///{shellItem.Route}");
}
private async void BackButtonClicked(object sender, EventArgs e)
{
await GoToAsync("..");
}
}
Navigation between pages works almost the same as in .NET MAUI Shell
, just use the common Shell.Current.GoToAsync()
. SimpleShell
differs only in these cases:
- The
animate
parameter value has no effect on whether the transition animation is played or not. - When platform-specific transition animations are used, the
Task
returned by theGoToAsync()
method will complete once the navigation has been initiated, not once the animation has been completed. In other words, the returnedTask
is not waiting for the animation to complete. The same applies toNavigated
events.
Pages that are not part of the shell hierarchy can be registered using the Routing.RegisterRoute()
method.
Why not use SimpleShell
and use .NET MAUI Shell
instead
- .NET MAUI
Shell
offers a platform-specific appearance. - Platform-specific navigation controls that .NET MAUI
Shell
provides probably have better performance than controls composed of multiple .NET MAUI views. - A
SimpleShell
-based application may not have as good accessibility in some scenarios due to the lack of platform-specific navigation controls. .NET MAUIShell
should be accessible out of the box since it uses platform-specific controls. - Maybe I have implemented something wrong that has a negative impact on the performance, accessibility, or something like that.
See documentation for more information.
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-ios17.2 is compatible. net8.0-maccatalyst was computed. net8.0-maccatalyst17.2 is compatible. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows10.0.19041 is compatible. |
-
net8.0
- Microsoft.Maui.Controls (>= 8.0.40)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.40)
-
net8.0-android34.0
- Microsoft.Maui.Controls (>= 8.0.40)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.40)
-
net8.0-ios17.2
- Microsoft.Maui.Controls (>= 8.0.40)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.40)
-
net8.0-maccatalyst17.2
- Microsoft.Maui.Controls (>= 8.0.40)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.40)
-
net8.0-windows10.0.19041
- Microsoft.Maui.Controls (>= 8.0.40)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.40)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on SimpleToolkit.SimpleShell:
Repository | Stars |
---|---|
RadekVyM/MarvelousMAUI
.NET MAUI clone of the Wonderous app - a visual showcase of eight wonders of the world.
|
|
RadekVyM/SimpleToolkit
SimpleToolkit is a .NET MAUI library of helpers and simple, fully customizable controls, such as SimpleShell - custom Shell implementation that allows you to create unique navigation experiences.
|
Version | Downloads | Last updated |
---|---|---|
4.1.3 | 2,353 | 6/12/2024 |
4.1.0 | 2,413 | 2/1/2024 |
4.0.0 | 3,870 | 11/17/2023 |
3.0.1 | 3,369 | 7/22/2023 |
3.0.0 | 2,219 | 7/1/2023 |
2.1.1 | 984 | 4/29/2023 |
2.1.0 | 2,647 | 3/4/2023 |
2.0.1 | 1,239 | 2/3/2023 |
2.0.0 | 1,314 | 11/11/2022 |
1.1.0 | 964 | 10/24/2022 |
1.0.0 | 1,105 | 9/19/2022 |
1.0.0-preview2 | 678 | 9/9/2022 |
1.0.0-preview1 | 774 | 9/7/2022 |