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
<PackageReference Include="CG.Infrastructure.Navigation" Version="3.10.3" />
<PackageVersion Include="CG.Infrastructure.Navigation" Version="3.10.3" />
<PackageReference Include="CG.Infrastructure.Navigation" />
paket add CG.Infrastructure.Navigation --version 3.10.3
#r "nuget: CG.Infrastructure.Navigation, 3.10.3"
#:package CG.Infrastructure.Navigation@3.10.3
#addin nuget:?package=CG.Infrastructure.Navigation&version=3.10.3
#tool nuget:?package=CG.Infrastructure.Navigation&version=3.10.3
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 tabsIWorkspaceRegistryService
: Manages workspace registration and discoveryIWorkspaceDefinitionService
: Handles workspace configuration and definitions
Entities
Workspace
: Represents a navigable workspace with tabs and contentTab
: Individual tab within a workspaceNavigationItem
: Navigation menu itemsWorkspaceDefinition
: Configuration for workspace setupTabDefinition
: Configuration for tab setup
ViewModels
WorkspaceBaseViewModel
: Base class for all workspace view modelsTabBaseViewModel
: Base class for tab view modelsWorkspaceViewModel
: 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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0-windows7.0 is compatible. net10.0-windows was computed. |
-
net9.0-windows7.0
- CG.Infrastructure.Core (>= 3.10.8)
- CG.Infrastructure.Presentation (>= 3.10.5)
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.