This is a base libraries for building WPF, WinUI, or Avalonia application with the MVVM design pattern.
- ViewModelBase - Base class with INotifyPropertyChanged
- MainWindowViewModelBase - Main window lifecycle management
- ViewModelDialogBase - Dialog-specific ViewModels
- ObservableObject - Lightweight observable pattern
- RelayCommand /
RelayCommand<T>
- Synchronous commands withCanExecute
support - RelayCommandAsync /
RelayCommandAsync<T>
- Async/await commands for responsive UIs - Automatic CanExecute refresh - Commands automatically update UI state
- Error handling support - Built-in
IErrorHandler
interface for graceful error management
Decouple your ViewModels with a powerful messaging infrastructure:
- Messenger - Central message bus for app-wide communication
- GenericMessage<T> - Send typed messages between components
- NotificationMessage - Simple notifications with optional callbacks
- PropertyChangedMessage<T> - Broadcast property changes across ViewModels
Perfect for scenarios like:
- Cross-ViewModel communication without direct references
- Event aggregation patterns
- Plugin architectures
- Loosely-coupled component communication
// Send a message
Messenger.Default.Send(new GenericMessage<User>(currentUser));
// Receive a message
Messenger.Default.Register<GenericMessage<User>>(this, msg =>
{
var user = msg.Content;
// Handle the user...
});
Learn more: Messaging System Documentation
Extensive collection of ready-to-use XAML converters for WPF, WinUI, and Avalonia:
BoolToInverseBoolValueConverter
BoolToVisibilityCollapsedValueConverter
BoolToVisibilityVisibleValueConverter
BoolToWidthValueConverter
MultiBoolToBoolValueConverter
(AND/OR logic)MultiBoolToVisibilityVisibleValueConverter
StringNullOrEmptyToBoolValueConverter
StringNullOrEmptyToInverseBoolValueConverter
StringNullOrEmptyToVisibilityVisibleValueConverter
StringNullOrEmptyToVisibilityCollapsedValueConverter
ToLowerValueConverter
/ToUpperValueConverter
See detailed Value Converters documentation
Eliminate boilerplate with powerful code generation:
- [ObservableProperty] - Auto-generate properties with change notification
- [RelayCommand] - Auto-generate command properties from methods
- [DependencyProperty] (WPF) - Auto-generate dependency properties
- [AttachedProperty] (WPF) - Auto-generate attached properties
- [RoutedEvent] (WPF) - Auto-generate routed events
Learn more about each generator:
- SourceGenerators for AttachedProperties
- SourceGenerators for DependencyProperties
- SourceGenerators for RoutedEvents
- SourceGenerators for ViewModel
- BooleanBoxes - Cached boolean boxing for reduced memory allocations
- WeakAction/WeakFunc - Memory-leak prevention for event handlers and callbacks
- PropertyDefaultValueConstants - Shared default values for common property types
- DesignModeHelper - Detect design-time vs runtime for better designer experience
- Base Converter Classes -
ValueConverterBase
andMultiValueConverterBase
for creating custom converters - Error Handling -
IErrorHandler
interface for centralized command error management
Install via NuGet Package Manager or .NET CLI:
For WPF:
dotnet add package Atc.XamlToolkit.Wpf
For WinUI:
dotnet add package Atc.XamlToolkit.WinUI
For Avalonia:
dotnet add package Atc.XamlToolkit.Avalonia
// Create a ViewModel with source-generated properties and commands
public partial class MainViewModel : ViewModelBase
{
[ObservableProperty]
private string userName;
[ObservableProperty]
private bool isLoading;
[RelayCommand]
private async Task LoadDataAsync()
{
IsLoading = true;
// Load data...
IsLoading = false;
}
}
📖 Read the full Getting Started Guide for a complete walkthrough.
- .NET >= 9.0.202 - SDK
- .NET 9 - Runtime for Avalonia
- .NET 9 - Desktop Runtime for WPF
- .NET 9 - Desktop Runtime for WinUI 3
- Getting Started Guide - Complete walkthrough for beginners
- MVVM Framework - ViewModels, Commands, and MVVM patterns
- Messaging System - Decoupled communication between components
- Source Generators - Eliminate boilerplate code
- Value Converters - Complete converter reference
- Performance Optimizations - BooleanBoxes, WeakAction, and more
- Utilities and Helpers - DesignModeHelper, base classes, and utilities
- Dependency Properties - Auto-generate dependency properties
- Attached Properties - Auto-generate attached properties
- Routed Events - Auto-generate routed events
Example for ViewModel classes with source generation:
For more details, see the MVVM section.
Component | Description | Package |
---|---|---|
ViewModelBase |
Base ViewModel with INotifyPropertyChanged | Atc.XamlToolkit |
MainWindowViewModelBase |
Main window lifecycle management | Atc.XamlToolkit.Wpf/WinUI/Avalonia |
ViewModelDialogBase |
Dialog-specific ViewModels | Atc.XamlToolkit |
ObservableObject |
Lightweight observable pattern | Atc.XamlToolkit |
Command | Description | Async Support |
---|---|---|
RelayCommand |
Synchronous command | No |
RelayCommand<T> |
Synchronous command with parameter | No |
RelayCommandAsync |
Asynchronous command | Yes |
RelayCommandAsync<T> |
Asynchronous command with parameter | Yes |
All commands support:
- ✅
CanExecute
with automatic refresh - ✅ Error handling via
IErrorHandler
- ✅ Auto-generation via
[RelayCommand]
attribute
Type | Purpose |
---|---|
Messenger |
Central message bus |
GenericMessage<T> |
Typed message passing |
NotificationMessage |
String-based notifications |
NotificationMessageAction |
Messages with callbacks |
NotificationMessageAction<T> |
Messages with parameterized callbacks |
PropertyChangedMessage<T> |
Property change broadcasts |
NotificationMessageWithCallback |
Generic callback support |
Generator | Platform | Description |
---|---|---|
[ObservableProperty] |
WPF, WinUI, Avalonia | Auto-generate observable properties |
[RelayCommand] |
WPF, WinUI, Avalonia | Auto-generate command properties |
[DependencyProperty] |
WPF only | Auto-generate dependency properties |
[AttachedProperty] |
WPF only | Auto-generate attached properties |
[RoutedEvent] |
WPF only | Auto-generate routed events |
Bool Converters (WPF, WinUI & Avalonia):
BoolToInverseBoolValueConverter
BoolToVisibilityCollapsedValueConverter
BoolToVisibilityVisibleValueConverter
BoolToWidthValueConverter
MultiBoolToBoolValueConverter
MultiBoolToVisibilityVisibleValueConverter
String Converters (WPF, WinUI & Avalonia):
StringNullOrEmptyToBoolValueConverter
StringNullOrEmptyToInverseBoolValueConverter
StringNullOrEmptyToVisibilityVisibleValueConverter
StringNullOrEmptyToVisibilityCollapsedValueConverter
ToLowerValueConverter
ToUpperValueConverter
Optimization | Benefit |
---|---|
BooleanBoxes |
Zero-allocation boolean boxing |
WeakAction |
Memory leak prevention |
WeakFunc<T> |
Memory leak prevention with return values |
PropertyDefaultValueConstants |
Shared default values |
Utility | Purpose |
---|---|
DesignModeHelper |
Detect design-time vs runtime |
ValueConverterBase |
Base class for custom converters |
MultiValueConverterBase |
Base class for multi-value converters |
IErrorHandler |
Centralized error handling |
- ✅ Modern - Built for .NET 9 with latest C# features
- ✅ Cross-platform - Supports WPF, WinUI 3, and Avalonia
- ✅ High Performance - Optimized for minimal allocations
- ✅ Source Generators - Eliminate boilerplate code
- ✅ Well Documented - Comprehensive documentation and examples
- ✅ Battle Tested - Used in production applications
- ✅ Open Source - MIT licensed and community-driven