AvaloniaInside.Shell
0.1.2-alpha
See the version list below for details.
dotnet add package AvaloniaInside.Shell --version 0.1.2-alpha
NuGet\Install-Package AvaloniaInside.Shell -Version 0.1.2-alpha
<PackageReference Include="AvaloniaInside.Shell" Version="0.1.2-alpha" />
paket add AvaloniaInside.Shell --version 0.1.2-alpha
#r "nuget: AvaloniaInside.Shell, 0.1.2-alpha"
// Install AvaloniaInside.Shell as a Cake Addin #addin nuget:?package=AvaloniaInside.Shell&version=0.1.2-alpha&prerelease // Install AvaloniaInside.Shell as a Cake Tool #tool nuget:?package=AvaloniaInside.Shell&version=0.1.2-alpha&prerelease
Shell
Avalonia Inside Shell reduces the complexity of mobile/desktop application development by providing the fundamental features that most applications require, including:
A single place to describe the visual hierarchy of an application.
A common navigation user experience.
A URI-based navigation scheme that permits navigation to any page in the application
This project is currently in alpha stage of development. This means that it is still being designed and built, and it has not been thoroughly tested yet. It may contain serious errors, bugs, or missing features that could affect its functionality and performance. Use it at your own risk and do not rely on it for any critical purposes.
We welcome feedback, suggestions, and contributions from anyone who is interested in this project. We appreciate your support and patience as we work towards releasing a stable version of this project.
Screenshots
<img src="https://user-images.githubusercontent.com/956077/226295190-cbe81c7d-4054-4c07-9e5c-7ee7149c1468.png" width="300"/> <img src="https://user-images.githubusercontent.com/956077/226295294-3d4f1f9e-941d-4248-b941-a0c35ca0533a.png" width="300"/>
Installation
To use AvaloniaInside.Shell in your Avalonia project, you can install the package via NuGet using the following command in the Package Manager Console:
dotnet add package AvaloniaInside.Shell --version 0.1.2-alpha
Alternatively, you can also install the package through Visual Studio's NuGet Package Manager.
Add dependencies to the Locator or call Program.cs
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI()
.UseShell();
Add default theme or add your custom theme to the App.axmal file
<StyleInclude Source="avares://AvaloniaInside.Shell/Default.axaml"></StyleInclude>
Using Shell
Adding a ShellView
To use a ShellView in your application, you can add it to your XAML file like this:
<ShellView>
</ShellView>
Basic Usage Guide for Shell and Navigation
You can register navigation using the Host
and Route
elements. Host
can be used to group pages under a common root, such as a TabControl
. Here's an example:
<ShellView Name="MyShellView">
<Host Path="main" Page="views:MainTabControl">
<Route Path="home" Page="views:HomePage">
<Route Path="confirmation" Page="views:SimpleDialog" Type="Modal"></Route>
</Route>
<Host Path="pets" Page="views:PetsTabControlView" Default="cat">
<Route Path="cat" Page="views:CatView"></Route>
<Route Path="dog" Page="views:DogView"></Route>
</Host>
<Route Path="product" Page="shopViews:ProductCatalogView">
<Route Path="filter" Page="shopViews:ProductCatalogFilterView" Type="Modal"></Route>
</Route>
<Route Path="setting" Page="views:SettingView">
<Route Path="profile" Page="views:ProfileView"></Route>
</Route>
</Host>
</ShellView>
And to navigate to a specific page, we can use the Navigator property of the ShellView, as follows:
await MyShellView.Navigator.NavigateAsync("/main/home/confirmation", cancellationToken);
NavigationBar
Each page that is currently on top of the navigation stack has access to the navigation bar's title and navigation item. In hierarchical hosts, the currently selected item in the host will be the one that has access to the navigation bar. For example, in the case of /home/pets/cat, the page associated with the cat would be able to modify the navigation bar. This can be done by setting the NavigationBar.Header and NavigationBar.Item properties, as shown in the code snippet below:
<UserControl xmlns="https://github.com/avaloniaui"
x:Class="ShellExample.Views.ShopViews.ProductCatalogView"
NavigationBar.Header="Products">
<NavigationBar.Item>
<Button Content="Filter" Command="{Binding FilterCommand}"></Button>
</NavigationBar.Item>
...
</UserControl>
ShellView content's support
IItem
is the base interface for all items that can be added to the ShellView
's content. It has the following properties:
Route
Route
is a type of IItem
that represents a navigation route in the ShellView
. It has a Page
property that specifies the view associated with the route, as well as an optional Type
property that specifies the navigation type, And Path
is the property to register navigate.
Host
Host
can be used to group pages under a common root, such as a TabControl
.
It has a Page
property that specifies the view associated with the host, as well as an optional Default
property that specifies the default child route. as well as a Children
property that specifies any child Route
objects.
SideMenuItem
SideMenuItem
is another type of item that can be used to display navigation options in the ShellView's side menu. It also inherits from IItem
and has the following properties:
Icon
: An icon to display next to the item's label in the side menu.
Title
: The text label to display for the item in the side menu.
Path
: The path of navigation.
Example of Side Menu usage
<UserControl xmlns="https://github.com/avaloniaui" ...>
<ShellView Name="ShellViewMain" DefaultRoute="/main">
<Host Path="main" Page="views:MainTabControl"> ... </Host>
<ShellView.SideMenuHeader>
<widgets:UserProfileWidgetView></widgets:UserProfileWidgetView>
</ShellView.SideMenuHeader>
<SideMenuItem Path="/main/home" Title="Home" Icon="/Assets/Icons/house-solid.png"></SideMenuItem>
<SideMenuItem Path="/main/pets/cat" Title="Cat" Icon="/Assets/Icons/cat-solid.png"></SideMenuItem>
<SideMenuItem Path="/main/pets/dog" Title="Dog" Icon="/Assets/Icons/dog-solid.png"></SideMenuItem>
<SideMenuItem Path="/main/product" Title="Products" Icon="/Assets/Icons/tag-solid.png"></SideMenuItem>
<SideMenuItem Path="/main/setting" Title="Settings" Icon="/Assets/Icons/user-solid.png"></SideMenuItem>
<SideMenuItem Path="/second" Title="Second Click" Icon="/Assets/Icons/check-solid.png"></SideMenuItem>
<ShellView.SideMenuContents>
<widgets:WeatherView Margin="0, 20, 0, 0" />
<widgets:CalendarWidgetView Margin="0, 20, 0, 0" />
</ShellView.SideMenuContents>
<ShellView.SideMenuFooter>
<Border Background="#11000000" Height="25">
<TextBlock Text="AvaloniaInside Shell 2023"
FontWeight="Light"
VerticalAlignment="Center"
HorizontalAlignment="Center">
</TextBlock>
</Border>
</ShellView.SideMenuFooter>
</ShellView>
</UserControl>
In the code above side menu will contains 6 navigate route and will link selected item to the current route.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
-
net6.0
- Avalonia (>= 11.0.0-preview7)
- Avalonia.ReactiveUI (>= 11.0.0-preview7)
- Avalonia.Themes.Fluent (>= 11.0.0-preview7)
- XamlNameReferenceGenerator (>= 1.3.4)
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 |
---|---|---|
1.2.0 | 612 | 8/23/2024 |
1.1.3 | 689 | 4/5/2024 |
1.1.2 | 812 | 12/10/2023 |
1.1.1 | 169 | 12/4/2023 |
1.1.0 | 558 | 9/16/2023 |
1.0.0 | 255 | 7/8/2023 |
0.1.2.1 | 177 | 6/3/2023 |
0.1.2-alpha | 131 | 5/8/2023 |
0.1.1-alpha | 157 | 3/23/2023 |
0.1.0-alpha | 161 | 3/20/2023 |