GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Gitii/Community.Sextant.WinUI: A ReactiveUI navigation library for WinUI 3

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
.config
.config
 
 
.github/workflows
.github/workflows
 
 
.my-config
.my-config
 
 
Assets
Assets
 
 
Community.Sextant.WinUI.Microsoft.Extensions.DependencyInjection
Community.Sextant.WinUI.Microsoft.Extensions.DependencyInjection
 
 
Community.Sextant.WinUI.Splat
Community.Sextant.WinUI.Splat
 
 
Community.Sextant.WinUI.Tests
Community.Sextant.WinUI.Tests
 
 
Community.Sextant.WinUI
Community.Sextant.WinUI
 
 
SextantSample.Core
SextantSample.Core
 
 
SextantSample.WinUI.FrameOnly
SextantSample.WinUI.FrameOnly
 
 
SextantSample.WinUI.FrameWithNavigationView
SextantSample.WinUI.FrameWithNavigationView
 
 
SextantSample.WinUI
SextantSample.WinUI
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.onsaveconfig
.onsaveconfig
 
 
.prettierignore
.prettierignore
 
 
Community.Sextant.WinUI.sln
Community.Sextant.WinUI.sln
 
 
Directory.Build.props
Directory.Build.props
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
SextantSample.sln
SextantSample.sln
 
 

Repository files navigation

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:

  • reactiveui/splat: Makes things cross-platform:

    dotnet add Community.Sextant.WinUI.Splat
  • Microsoft.Extensions.DependencyInjection:

    dotnet add Community.Sextant.WinUI.Microsoft.Extensions.DependencyInjection

    NOTE: Sextant and reactiveui both always use Splat but Splat can use Microsoft.Extensions.DependencyInjection as internal dependency resolver. Please see the Advanced Integration Tutorial of Splat for more details.

  • Your favorite DI: Please create a feature request for it!

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.

Frame Frame and NavigationView Advanced
A simple Frame only A Frame and NavigationView Integrate any control!

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.

About

A ReactiveUI navigation library for WinUI 3

Topics

navigation-libraryreactiveuisextantwinui3

Resources

Readme
MIT license
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.