CG.Infrastructure.Navigation 3.10.3

dotnet add package CG.Infrastructure.Navigation --version 3.10.3
                    
NuGet\Install-Package CG.Infrastructure.Navigation -Version 3.10.3
                    
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="CG.Infrastructure.Navigation" Version="3.10.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CG.Infrastructure.Navigation" Version="3.10.3" />
                    
Directory.Packages.props
<PackageReference Include="CG.Infrastructure.Navigation" />
                    
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 CG.Infrastructure.Navigation --version 3.10.3
                    
#r "nuget: CG.Infrastructure.Navigation, 3.10.3"
                    
#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 CG.Infrastructure.Navigation@3.10.3
                    
#: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=CG.Infrastructure.Navigation&version=3.10.3
                    
Install as a Cake Addin
#tool nuget:?package=CG.Infrastructure.Navigation&version=3.10.3
                    
Install as a Cake Tool

Infrastructure.Navigation

A comprehensive navigation library for WPF applications that provides shared services and base view models for managing workspaces, tabs, and navigation within desktop applications.

Overview

Infrastructure.Navigation is part of the CG Infrastructure library suite, designed to provide a robust foundation for building navigable WPF applications with workspace and tab management capabilities. It leverages the MVVM pattern and integrates with other infrastructure components to deliver a consistent navigation experience.

Features

  • Workspace Management: Create, navigate between, and manage multiple workspaces
  • Tab Management: Handle multiple tabs within workspaces with dynamic content
  • Navigation Service: Centralized navigation control with event-driven architecture
  • Base ViewModels: Pre-built base classes for workspaces and tabs
  • WPF Integration: Native WPF support with XAML views and code-behind
  • MVVM Pattern: Built on CommunityToolkit.Mvvm for modern MVVM development
  • Dependency Injection: Full integration with Microsoft.Extensions.DependencyInjection

Architecture

Core Components

Services
  • INavigationService: Main navigation orchestrator managing workspaces and tabs
  • IWorkspaceRegistryService: Manages workspace registration and discovery
  • IWorkspaceDefinitionService: Handles workspace configuration and definitions
Entities
  • Workspace: Represents a navigable workspace with tabs and content
  • Tab: Individual tab within a workspace
  • NavigationItem: Navigation menu items
  • WorkspaceDefinition: Configuration for workspace setup
  • TabDefinition: Configuration for tab setup
ViewModels
  • WorkspaceBaseViewModel: Base class for all workspace view models
  • TabBaseViewModel: Base class for tab view models
  • WorkspaceViewModel: Standard workspace implementation
Views
  • WorkspaceView: Default workspace view with tab management

Getting Started

Prerequisites

  • .NET 9.0 or later
  • WPF support enabled
  • Infrastructure.Core dependency
  • Infrastructure.Presentation dependency

Installation

<PackageReference Include="CG.Infrastructure.Navigation" Version="3.10.0" />

Basic Usage

1. Register Services
services.AddScoped<INavigationService, NavigationService>();
services.AddScoped<IWorkspaceRegistryService, WorkspaceRegistryService>();
services.AddScoped<IWorkspaceDefinitionService, WorkspaceDefinitionService>();
2. Create a Workspace ViewModel
public partial class MyWorkspaceViewModel : WorkspaceBaseViewModel
{
    public override string WorkspaceId => "MyWorkspace";
    
    public override string Title => "My Workspace";
    public override string Description => "A custom workspace";
    public override string Icon => "🚀";
    public override int WorkspaceOrder => 1;
}
3. Navigate to Workspace
var workspace = await navigationService.NavigateToWorkspaceAsync(
    typeof(MyWorkspaceViewModel), 
    typeof(MyWorkspaceView), 
    "My Workspace", 
    "Custom workspace description"
);
4. Add Tabs
var tab = await navigationService.NavigateToTabAsync(
    typeof(MyTabViewModel), 
    typeof(MyTabView), 
    "My Tab", 
    "📋"
);

Advanced Features

Custom Navigation Items

Override InitilizeNavigationItems in your workspace view model to add custom navigation:

protected override void InitilizeNavigationItems(WorkspaceDefinition workspaceDefinition)
{
    NavigationItems.Add(new NavigationItem 
    { 
        Title = "Custom Action",
        Command = new RelayCommand(ExecuteCustomAction)
    });
}

Workspace Definitions

Define workspace configurations for dynamic loading:

var definition = new WorkspaceDefinition
{
    ViewType = typeof(MyWorkspaceView).FullName,
    Title = "Dynamic Workspace",
    Description = "Created at runtime"
};

Tab Management

Manage tabs programmatically:

// Close a tab
await navigationService.CloseTabAsync(tab);

// Select a specific tab
await navigationService.SelectTabAsync(tab);

// Get current tab
var currentTab = navigationService.CurrentTab;

Dependencies

  • CG.Infrastructure.Core (v3.10.7): Core infrastructure services
  • CG.Infrastructure.Presentation (v3.10.3): Presentation layer components
  • CommunityToolkit.Mvvm: MVVM toolkit for WPF
  • Microsoft.Extensions.DependencyInjection: Dependency injection container
  • Microsoft.Extensions.Logging: Logging infrastructure

Target Framework

  • .NET 9.0-windows: Windows-specific WPF support
  • WPF Enabled: Full WPF integration
  • Nullable Reference Types: Modern C# null safety features

Contributing

This library is part of the CG Infrastructure suite. Contributions should follow the established patterns and maintain compatibility with the broader infrastructure ecosystem.

License

See the LICENSE file in the root directory for licensing information.

Version History

  • 3.10.0: Current version with .NET 9.0 support and WPF integration

Support

For issues, questions, or contributions, please refer to the main Infrastructure repository or contact the development team.

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

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CG.Infrastructure.Navigation:

Package Downloads
CG.Platform.Presentation

Platform Presentation library with shared services

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.10.3 18 8/16/2025
3.10.2 58 8/15/2025
3.10.1 95 8/13/2025
3.10.0 90 8/10/2025