DotNetTools.Wpfkit
1.0.0
See the version list below for details.
dotnet add package DotNetTools.Wpfkit --version 1.0.0
NuGet\Install-Package DotNetTools.Wpfkit -Version 1.0.0
<PackageReference Include="DotNetTools.Wpfkit" Version="1.0.0" />
<PackageVersion Include="DotNetTools.Wpfkit" Version="1.0.0" />
<PackageReference Include="DotNetTools.Wpfkit" />
paket add DotNetTools.Wpfkit --version 1.0.0
#r "nuget: DotNetTools.Wpfkit, 1.0.0"
#:package DotNetTools.Wpfkit@1.0.0
#addin nuget:?package=DotNetTools.Wpfkit&version=1.0.0
#tool nuget:?package=DotNetTools.Wpfkit&version=1.0.0
DotNetTools.Wpfkit
A comprehensive WPF toolkit library that provides essential components for building modern Windows desktop applications with the MVVM pattern, logging capabilities, and configuration management.
?? Table of Contents
?? Overview
DotNetTools.Wpfkit is a modern .NET library designed to accelerate WPF application development by providing reusable, production-ready components. Built on .NET 10.0, it embraces modern C# features including nullable reference types, implicit usings, and follows best practices for WPF development.
? Features
MVVM Pattern Support
- ObservableObject: Base class implementing
INotifyPropertyChangedwith helper methods - BaseViewModel: Feature-rich view model base class with common UI properties
- ObservableRangeCollection<T>: Enhanced observable collection supporting bulk operations
Logging Infrastructure
- Serilog Integration: Built-in support for structured logging
- LogManager: Simplified logger creation with context-aware logging
- UserName Enricher: Custom enrichers for enhanced log metadata
Configuration Management
- AppSettingsUpdater: Utility for runtime appsettings.json manipulation
- Connection String Management: Easy database connection string updates
?? Installation
NuGet Package
dotnet add package DotNetTools.Wpfkit
Or via Package Manager Console in Visual Studio:
Install-Package DotNetTools.Wpfkit
Or add directly to your .csproj:
<PackageReference Include="DotNetTools.Wpfkit" Version="1.0.0" />
Manual Installation
- Clone the repository
- Build the project
- Reference the DLL in your WPF application
git clone https://github.com/omostan/DotNetTools.Wpfkit
cd DotNetTools.Wpfkit
dotnet build
?? Requirements
- .NET 10.0 or later
- Windows OS (for WPF support)
- Visual Studio 2022 or later (recommended)
Dependencies
- Serilog (v4.3.0+): Structured logging
- Tracetool.DotNet.Api (v14.0.0+): Advanced tracing capabilities
?? Usage
MVVM Components
ObservableObject
Base class for implementing property change notifications:
using DotNetTools.Wpfkit.MvvM;
public class MyModel : ObservableObject
{
private string _name;
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
private int _age;
public int Age
{
get => _age;
set => SetProperty(ref _age, value, onChanged: () => {
// Execute when age changes
OnPropertyChanged(nameof(IsAdult));
});
}
public bool IsAdult => Age >= 18;
}
BaseViewModel
Rich view model base class with common UI properties:
using DotNetTools.Wpfkit.MvvM;
public class MainViewModel : BaseViewModel
{
public MainViewModel()
{
Title = "My Application";
Subtitle = "Welcome Screen";
Icon = "icon.png";
}
public async Task LoadDataAsync()
{
IsBusy = true;
try
{
// Load data
}
finally
{
IsBusy = false;
}
}
}
Available Properties:
Title: Main title textSubtitle: Secondary descriptive textIcon: Icon path or resourceIsBusy: Indicates loading stateIsNotBusy: Inverse of IsBusyCanLoadMore: Pagination supportHeader: Header contentFooter: Footer content
ObservableRangeCollection<T>
Enhanced collection with bulk operations:
using DotNetTools.Wpfkit.MvvM;
var collection = new ObservableRangeCollection<string>();
// Add multiple items efficiently
var items = new[] { "Item1", "Item2", "Item3" };
collection.AddRange(items);
// Replace entire collection
collection.ReplaceRange(newItems);
// Remove multiple items
collection.RemoveRange(itemsToRemove);
// Replace with single item
collection.Replace(singleItem);
AddRange Notification Modes:
NotifyCollectionChangedAction.Add: Notify for each added item (default)NotifyCollectionChangedAction.Reset: Single reset notification
Logging
Setting Up the Logger
using DotNetTools.Wpfkit.Logging.Extensions;
using Serilog;
public class MyService
{
// Get logger for current class
private static readonly ILogger Log = LogManager.GetCurrentClassLogger();
public void DoWork()
{
Log.Me().Information("Starting work at line {LineNumber}");
try
{
// Your code here
Log.Me().Debug("Processing item");
}
catch (Exception ex)
{
Log.Me().Error(ex, "Failed to process item");
}
}
}
LogManager Features:
GetCurrentClassLogger(): Automatically creates logger with calling class contextMe()extension: Adds line number information to log entries
Serilog Configuration Example
using Serilog;
using DotNetTools.Wpfkit.Logging.Enrichers;
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.Enrich.With<UserNameEnricher>()
.WriteTo.Console()
.WriteTo.File("logs/app.log", rollingInterval: RollingInterval.Day)
.CreateLogger();
Configuration Management
Updating Connection Strings
using DotNetTools.Wpfkit.Database;
// Update connection string in appsettings.json
string connectionString = "Data Source=myserver;Initial Catalog=mydb;";
AppSettingsUpdater.UpdateConnectionString(connectionString);
Features:
- Automatically locates appsettings.json in application directory
- Safely updates
ConnectDatabaseproperty - Handles "Data Source=" prefix trimming
- Comprehensive error handling and logging
- Writes formatted JSON (indented)
appsettings.json Structure:
{
"ConnectDatabase": "path/to/database.db",
"OtherSettings": "..."
}
?? API Reference
MvvM Namespace
ObservableObject
protected bool SetProperty<T>(
ref T backingStore,
T value,
string propertyName = "",
Action onChanged = null,
Func<T, T, bool> validateValue = null)
- backingStore: Reference to the backing field
- value: New value to set
- propertyName: Property name (auto-filled via CallerMemberName)
- onChanged: Optional callback when value changes
- validateValue: Optional validation function
- Returns:
trueif property changed,falseotherwise
BaseViewModel Properties
| Property | Type | Description |
|---|---|---|
| Title | string | Main title text |
| Subtitle | string | Secondary descriptive text |
| Icon | string | Icon path or resource identifier |
| IsBusy | bool | Indicates if operation is in progress |
| IsNotBusy | bool | Inverse of IsBusy (auto-synchronized) |
| CanLoadMore | bool | Supports pagination scenarios |
| Header | string | Header content |
| Footer | string | Footer content |
ObservableRangeCollection<T> Methods
void AddRange(IEnumerable<T> collection,
NotifyCollectionChangedAction notificationMode = Add)
void RemoveRange(IEnumerable<T> collection,
NotifyCollectionChangedAction notificationMode = Reset)
void Replace(T item)
void ReplaceRange(IEnumerable<T> collection)
Logging Namespace
LogManager
static ILogger GetCurrentClassLogger()
static ILogger Me(this ILogger logger, int sourceLineNumber = 0)
Database Namespace
AppSettingsUpdater
static void UpdateConnectionString(string connectionString)
??? Architecture
Project Structure
DotNetTools.Wpfkit/
??? MvvM/
? ??? ObservableObject.cs # Base observable implementation
? ??? BaseViewModel.cs # Rich view model base class
? ??? ObservableRangeCollection.cs # Bulk operations collection
??? Logging/
? ??? Extensions/
? ? ??? LogManager.cs # Logger factory
? ? ??? UserName.cs # Username helper
? ??? Enrichers/
? ??? UserNameEnricher.cs # Serilog enricher
??? Database/
? ??? AppSettingsUpdater.cs # Configuration management
??? DotNetTools.Wpfkit.csproj
Design Principles
- SOLID Principles: Clean, maintainable code architecture
- Separation of Concerns: Each component has a single responsibility
- Reusability: Generic, flexible implementations
- Performance: Optimized bulk operations in collections
- Type Safety: Leverages nullable reference types
?? Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Coding Standards
- Follow C# coding conventions
- Use meaningful variable and method names
- Add XML documentation comments
- Include unit tests for new features
- Maintain the existing copyright header format
?? License
Copyright � 2025 Omotech Digital Solutions
Licensed under the MIT License.
This project is open source software created by Stanley Omoregie.
?? Contact
Author: Stanley Omoregie
Organization: Omotech Digital Solutions
Created: November 20, 2025
For questions, issues, or feature requests, please open an issue on the repository.
?? Version History
Version 1.0.0 (2025-11-20)
- Initial release
- MVVM pattern components (ObservableObject, BaseViewModel, ObservableRangeCollection)
- Serilog logging integration
- AppSettings configuration management
- .NET 10.0 support
?? Learning Resources
WPF & MVVM
Serilog
.NET 10
Built with ?? using .NET 10.0 and modern C# features
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- Serilog (>= 4.3.0)
- Tracetool.DotNet.Api (>= 14.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release of DotNetTools.Wpfkit with MVVM components, logging extensions, and configuration utilities.