OutWit.Common.MVVM.Navigation.WPF 1.0.0

dotnet add package OutWit.Common.MVVM.Navigation.WPF --version 1.0.0
                    
NuGet\Install-Package OutWit.Common.MVVM.Navigation.WPF -Version 1.0.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="OutWit.Common.MVVM.Navigation.WPF" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OutWit.Common.MVVM.Navigation.WPF" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OutWit.Common.MVVM.Navigation.WPF" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OutWit.Common.MVVM.Navigation.WPF --version 1.0.0
                    
#r "nuget: OutWit.Common.MVVM.Navigation.WPF, 1.0.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.
#:package OutWit.Common.MVVM.Navigation.WPF@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OutWit.Common.MVVM.Navigation.WPF&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OutWit.Common.MVVM.Navigation.WPF&version=1.0.0
                    
Install as a Cake Tool

OutWit.Common.MVVM.Navigation.WPF

The WPF half of OutWit.Common.MVVM.Navigation. It lets a WPF application drop Prism and Unity while staying on WPF — the infrastructure changes, the UI framework does not.

Runnable sample: OutWit.Common.MVVM.Navigation.WPF.Sample, which binds the same view models the Avalonia sample does.

  • ViewLocator — the core's IViewFactory and a DataTemplateSelector: the view registry first (the only path under trimming/AOT), then a naming convention searched in the view model's own assembly. Created from DI so views may take dependencies. Its templates hold a ViewPresenter, so DI-built views work inside any ContentControl or ItemsControl.
  • NavigationOutlet — a control that hosts an INavigationOutlet and owns the views: for Cached routes the view of each view model survives navigations (scroll position, column widths, expensive controls), for Transient routes it goes with the view model. Set TransitionDuration to fade between screens; the fade is on the outlet itself, so a cached view is never asked to be in two places at once, and a fade that is overtaken hands over cleanly.
  • ViewPresenter — shows the view of any view model: nested content, zone widgets.
  • DialogHostWindowIDialogHost over modal windows; dialogs nest; the close button goes through the dialog's CanCloseAsync.
  • IApplicationResources — lets a UI module merge its resource dictionaries.
  • AddWpfNavigation() — registers all of the above plus WpfDispatcher as IDispatcher.

Setup

// App.xaml.cs
protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);

    var services = new ServiceCollection();
    services.AddNavigation(nav =>
    {
        nav.AddRoute<StudiesViewModel>(Routes.STUDIES);
        nav.AddRoute<StudyViewModel>(Routes.STUDY, NavigationRouteMode.Transient);
    });
    services.AddWpfNavigation();                          // or AddWpfNavigation(o => o.UseDialogHost<MyMaterialHost>())
    services.AddSingleton<ShellViewModel>();

    var provider = services.BuildServiceProvider();
    provider.UseWpfViewLocator();                         // Application.Resources["OutWit.Navigation.ViewLocator"]
    provider.ValidateNavigation(throwOnProblems: Debugger.IsAttached);

    MainWindow = new ShellWindow { DataContext = provider.GetRequiredService<ShellViewModel>() };
    MainWindow.Show();

    _ = provider.GetRequiredService<INavigationService>().NavigateAsync(Routes.STUDIES);
}

<Window xmlns:n="https://schemas.outwit.io/navigation">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" /><ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <ItemsControl ItemsSource="{Binding NavigationBar.Items}" />          
    <n:NavigationOutlet Grid.Column="1" Outlet="{Binding Main}" />        
  </Grid>
</Window>

Nested content anywhere: <n:ViewPresenter ViewModel="{Binding Widget}" /> or <ContentControl Content="{Binding Widget}" ContentTemplateSelector="{StaticResource OutWit.Navigation.ViewLocator}" />.

Views

Convention (ViewConvention) App.ViewModels.StudyViewModel
ViewModelsToViews (default) App.Views.StudyView, then App.ViewModels.StudyView
SameNamespace App.ViewModels.StudyView
None registry only

Explicit registration always wins: nav.AddView<StudyViewModel, StudyView>() or context.Views.Register<StudyViewModel, StudyView>() from a module.

The convention searches the view model's own assembly. Views that live in a different assembly from their view models — a shared view model layer, a per-platform view layer — have to be registered explicitly. That is also the only path that survives trimming.

Dialogs

DialogHostWindow wraps a non-Window view in a modal window centred on its owner; define a Style with key OutWit.Navigation.DialogWindow in the application resources to restyle it. A view that is a Window is shown as is. For MaterialDesignThemes' DialogHost, implement IDialogHost and pass it to UseDialogHost<T>().

License

Apache-2.0. Part of the OutWit ecosystem.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net9.0-windows7.0 is compatible.  net10.0-windows was computed.  net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.0 85 8/23/2026