A production-ready WPF MVVM framework built with modern .NET practices and comprehensive architecture patterns.
- Modern MVVM with CommunityToolkit.Mvvm source generators
- Dependency Injection using Microsoft.Extensions.DependencyInjection
- Async/Await patterns throughout
- Repository Pattern with Unit of Work for data access
- AvalonDock - Visual Studio-style docking windows
- Theme Management - Light/Dark themes with runtime switching
- Value Converters - Comprehensive library of XAML converters
- Validation - Both DataAnnotations and FluentValidation support
- Custom Controls - Reusable WPF controls
- Navigation Service - Type-safe navigation with parameters
- Dialog Service - Unified dialog management (messages, files, custom)
- Message Bus - Decoupled pub/sub communication
- Configuration Service - JSON-based configuration
- User Settings - Persistent user preferences
- Keyboard Shortcuts - Customizable keyboard shortcuts
- Logging - Structured logging with Serilog
- Theme Service - Runtime theme switching
WPFBase/
βββ Commands/ # Custom ICommand implementations
βββ Controls/ # Reusable WPF controls
βββ Converters/ # XAML value converters
βββ Data/ # Repository and data access
βββ Extensions/ # C# extension methods
βββ Interfaces/ # Service contracts
βββ Models/ # Data models and DTOs
βββ Resources/ # Icons, images, assets
βββ Services/ # Service implementations
βββ Themes/ # Application themes and styles
βββ Validators/ # FluentValidation validators
βββ ViewModels/ # MVVM ViewModels
βββ Views/ # XAML views and code-behind
βββ scripts/ # Build and utility scripts
Each folder contains a README.md explaining its purpose and usage patterns.
- .NET 9.0 SDK or later
- Visual Studio 2022 / VS Code / Rider
- Windows 10/11
git clone https://github.com/yourusername/WPFBase.git
cd WPFBase# Restore packages
dotnet restore
# Build the project
dotnet build
# Run the application
dotnet runCreate a ViewModel:
public partial class MyViewModel : ViewModelBase
{
private readonly IDialogService _dialogService;
public MyViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
Title = "My Feature";
}
[ObservableProperty]
private string message = "Hello World!";
[RelayCommand]
private async Task ShowMessageAsync()
{
await _dialogService.ShowInformationAsync(Message, "Info");
}
}Create a View:
<UserControl x:Class="WPFBase.Views.MyView">
<StackPanel Margin="20">
<TextBox Text="{Binding Message, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="Show Message" Command="{Binding ShowMessageCommand}" />
</StackPanel>
</UserControl>Register in DI Container (App.xaml.cs):
services.AddTransient<MyViewModel>();
services.AddTransient<MyView>();- CommunityToolkit.Mvvm 8.4.0 - Modern MVVM with source generators
- AvalonDock - Professional docking windows
- Serilog - Structured logging
- FluentValidation - Business rule validation
- WPF-UI - Modern UI components
- xUnit + Moq - Comprehensive testing
Uses modern CommunityToolkit.Mvvm patterns:
[ObservableProperty]for automatic property generation[RelayCommand]for automatic command generationObservableValidatorfor validation support
All services follow interface-based design:
- Easy to test with mocking
- Dependency injection throughout
- Clear separation of concerns
Type-safe navigation and comprehensive dialog system:
// Navigate to a view
await _navigationService.NavigateToAsync<CustomerViewModel>();
// Show dialogs
await _dialogService.ShowInformationAsync("Message", "Title");
var result = await _dialogService.ShowConfirmationAsync("Are you sure?");The framework includes comprehensive unit tests:
# Run all tests
dotnet test
# Run with coverage
dotnet test /p:CollectCoverage=true
# Run specific tests
dotnet test --filter "NavigationServiceTests"Each folder contains detailed README files explaining:
- Purpose and usage
- Code examples
- Best practices
- Common patterns
This framework is perfect for:
- Enterprise desktop applications
- Document-based applications (with docking)
- Configuration tools and utilities
- Data management applications
- Rapid prototyping with production-ready code
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT License - Use freely in commercial and open-source projects.
- Documentation: Check folder README files for detailed usage
- Issues: Report bugs and feature requests in GitHub Issues
- Examples: See the included sample ViewModels and Views
Built with modern .NET practices for robust, maintainable WPF applications.