SimpleToolkit.SimpleShell
2.1.1
See the version list below for details.
dotnet add package SimpleToolkit.SimpleShell --version 2.1.1
NuGet\Install-Package SimpleToolkit.SimpleShell -Version 2.1.1
<PackageReference Include="SimpleToolkit.SimpleShell" Version="2.1.1" />
paket add SimpleToolkit.SimpleShell --version 2.1.1
#r "nuget: SimpleToolkit.SimpleShell, 2.1.1"
// Install SimpleToolkit.SimpleShell as a Cake Addin
#addin nuget:?package=SimpleToolkit.SimpleShell&version=2.1.1
// Install SimpleToolkit.SimpleShell as a Cake Tool
#tool nuget:?package=SimpleToolkit.SimpleShell&version=2.1.1
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.
Getting Started
In order to use SimpleToolkit.SimpleShell, you need to call the UseSimpleShell()
extension method in your MauiProgram.cs
file:
builder.UseSimpleShell();
SimpleShell
SimpleShell
is a simplified implementation of .NET MAUI Shell
. All SimpleShell
is is just a simple container for your content with the ability to put the hosting area for pages wherever you want. Thanks to that, you are able to add custom tab bars, navigation bars, flyouts, etc. to your Shell
application while using great Shell
URI-based navigation.
<simpleShell:SimpleShell
x:Class="SimpleSample.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:SimpleSample.Views.Pages"
x:Name="thisShell">
<ShellContent
Title="Icons"
Icon="icon.png"
ContentTemplate="{DataTemplate pages:IconPage}"
Route="IconPage"/>
<ShellContent
Title="Buttons"
Icon="button.png"
ContentTemplate="{DataTemplate pages:ContentButtonPage}"
Route="ContentButtonPage"/>
<ShellContent
Title="Popovers"
Icon="popover.png"
ContentTemplate="{DataTemplate pages:PopoverPage}"
Route="PopoverPage"/>
<simpleShell:SimpleShell.Content>
<Grid
RowDefinitions="50, *, 50">
<Button
x:Name="backButton"
Clicked="BackButtonClicked"
Text="Back"
Margin="20,5"
HorizontalOptions="Start"
Background="DarkOrange"/>
<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"/>
<HorizontalStackLayout
x:Name="tabBar"
Grid.Row="2"
Margin="20,5"
HorizontalOptions="Center" Spacing="10"
BindableLayout.ItemsSource="{Binding ShellContents, Source={x:Reference thisShell}}">
<BindableLayout.ItemTemplate>
<DataTemplate
x:DataType="BaseShellItem">
<Button
Clicked="TabButtonClicked"
Background="DarkOrange"
Text="{Binding Title}"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</HorizontalStackLayout>
</Grid>
</simpleShell:SimpleShell.Content>
</simpleShell:SimpleShell>
As you can see, the logical navigation structure is defined with ShellContent
, Tab
, etc. as in normal .NET MAUI Shell
. However, visual structure has to be defined manually using the Content
property. The hosting area for pages is represented by the SimpleNavigationHost
view that can occur in the visual hierarchy just once.
SimpleShell provides you with some bindable properties which simplify the creation of custom navigation controls:
CurrentPage
- the currently selectedPage
CurrentShellSection
- the currently selectedShellSection
(Tab
)CurrentShellContent
- the currently selectedShellContent
ShellSections
- read-only list of allShellSection
s in the shellShellContents
- read-only list of allShellContent
s in the shellRootPageOverlay
- you can use this property to set a view that will be displayed over all root pages (ShellContent
s). This is well suited for tab bars, floating buttons, or flyouts that should be visible only on a root page
The code behind of the XAML sample above:
private async void TabButtonClicked(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 this.GoToAsync($"///{shellItem.Route}");
}
Navigation between pages works exactly the same as in .NET MAUI Shell
, just use the common Shell.Current.GoToAsync()
. 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 | net7.0 is compatible. net7.0-android was computed. net7.0-android33.0 is compatible. net7.0-ios was computed. net7.0-ios16.1 is compatible. net7.0-maccatalyst was computed. net7.0-maccatalyst16.1 is compatible. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net7.0-windows10.0.19041 is compatible. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- No dependencies.
-
net7.0-android33.0
- No dependencies.
-
net7.0-ios16.1
- No dependencies.
-
net7.0-maccatalyst16.1
- No dependencies.
-
net7.0-windows10.0.19041
- No dependencies.
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.0 | 1,223 | 2/1/2024 |
4.0.0 | 3,187 | 11/17/2023 |
3.0.1 | 2,942 | 7/22/2023 |
3.0.0 | 2,132 | 7/1/2023 |
2.1.1 | 954 | 4/29/2023 |
2.1.0 | 2,569 | 3/4/2023 |
2.0.1 | 1,195 | 2/3/2023 |
2.0.0 | 1,263 | 11/11/2022 |
1.1.0 | 935 | 10/24/2022 |
1.0.0 | 1,072 | 9/19/2022 |
1.0.0-preview2 | 654 | 9/9/2022 |
1.0.0-preview1 | 747 | 9/7/2022 |