Community.Sextant.WinUI 0.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Community.Sextant.WinUI --version 0.5.0                
NuGet\Install-Package Community.Sextant.WinUI -Version 0.5.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Community.Sextant.WinUI" Version="0.5.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Community.Sextant.WinUI --version 0.5.0                
#r "nuget: Community.Sextant.WinUI, 0.5.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Community.Sextant.WinUI as a Cake Addin
#addin nuget:?package=Community.Sextant.WinUI&version=0.5.0

// Install Community.Sextant.WinUI as a Cake Tool
#tool nuget:?package=Community.Sextant.WinUI&version=0.5.0                

Community.Sextant.WinUI

Community.Sextant.WinUI is a plugin for reactiveui/Sextant: A ReactiveUI navigation library. It adds support for Windows UI Library (WinUI) 3.

Getting Started

Installation

dotnet add Community.Sextant.WinUI

Depending on whichDependency Injection framework you are using, you can install a different helper package:

Configuration

Using Splat

In your App.xaml.cs:

public partial class App : Application
{
    public App()
    {
        this.InitializeComponent();

        Init();
    }

    /// Add this method and call in the constructor after this.InitializeComponent();
    void Init()
    {
        // Recommended
        RxApp.DefaultExceptionHandler = new SextantDefaultExceptionHandler();
        Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());
        
        // Required
        Locator.CurrentMutable
            .RegisterWinUIViewLocator()
            .RegisterParameterViewStackService()
            .RegisterViewStackServiceFromParameterService()
            .RegisterNavigationView()
            .RegisterConstantAnd<IDialogManager>(new DialogManager());
        // Will be expanded later...
    }
}

Using Microsoft DI:

public partial class App : Application
{
    public App()
    {
        this.InitializeComponent();

        Init();
    }

    // Add this code block

    public IServiceProvider? Container { get; private set; }

    /// Call this method in the constructor after this.InitializeComponent();
    void Init()
    {
        RxApp.DefaultExceptionHandler = new SextantDefaultExceptionHandler();
        var host = Host.CreateDefaultBuilder()
            .ConfigureServices(
                services =>
                {
                    services.UseMicrosoftDependencyResolver();
                    var resolver = Locator.CurrentMutable;
                    resolver.InitializeSplat();
                    resolver.InitializeReactiveUI();

                    // Configure our local services and access the host configuration
                    ConfigureServices(services);

                    // Configure Sextant, Views and ViewModels
                    services.UseSextant(
                        builder =>
                        {
                            builder.ConfigureDefaults();
                            builder.ConfigureViews(
                                viewBuilder =>
                                {
                                    // Will be expanded later...
                                }
                            );
                        }
                    );
                }
            )
            .UseEnvironment(Environments.Development)
            .Build();

        // Since MS DI container is a different type,
        // we need to re-register the built container with Splat again
        Container = host.Services;
        Container.UseMicrosoftDependencyResolver();
    }

    void ConfigureServices(IServiceCollection services)
    {
        // register your other services here
    }
}

Connect with your UI

Community.Sextant.WinUI needs to know where to push pages and models to. Typically a Frame Class is used for that. In combination with a NavigationView Class you can create a simple application with dynamic routing.

<div> <table> <tr> <td> <img src="./Assets/Frame.jpg" alt="Frame"> </td> <td> <img src="./Assets/NavView.jpg" alt="Frame and NavigationView"> </td> <td> <img src="./Assets/Adv.jpg" alt="Advanced"> </td> </tr> <tr> <td> A simple Frame only </td> <td> A Frame and NavigationView </td> <td> Integrate any control! </td> </tr> </table> </div>

A simple Frame
// Tell navigation service which <Frame /> to use
// A reference to the containing <Window /> is also needed for Popups.
_navigationService.SetAdapter(new FrameNavigationViewAdapter(MyFrame, MyWindow));

See SextantSample.WinUI.FrameOnly for a simple example.

A Frame and NavigationView
// Tell navigation service which <Frame /> && <NavigationView /> to use
// A reference to the containing <Window /> is also needed for Popups.
_navigationService.SetAdapter(
    new NavigationViewAdapter(MyFrame, MyWindow, MyNavigationView)
);

See SextantSample.WinUI.FrameWithNavigationView for an example.

Integrate any control

You can implement INavigationViewAdapter and cover your own use cases easily.

Add your view models

You need to register your Views and ViewModels other Sextant cannot find and create them. This is a separate step from the usual service registration.

Using Splat

Locator.CurrentMutable
    .RegisterViewWinUI(
        () => new MyView(),
        () => new MyViewModel()
    );

Using Microsoft DI:

viewBuilder.RegisterViewAndViewModel<
    MyView,
    MyViewModel
>();

viewBuilder is available in the ConfigureViews call.

Product Compatible and additional computed target framework versions.
.NET net5.0-windows10.0.19041 is compatible.  net6.0-windows was computed.  net6.0-windows10.0.19041 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Community.Sextant.WinUI:

Package Downloads
Community.Sextant.WinUI.Microsoft.Extensions.DependencyInjection

An adapter for Microsoft.Extensions.DependencyInjection for Community.Sextant.WinUI.

Community.Sextant.WinUI.Splat

An adapter for Splat for Community.Sextant.WinUI.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.6.1 376 2/15/2023
0.6.0 323 2/12/2023 0.6.0 is deprecated because it has critical bugs.
0.5.0 718 2/6/2022