WPFCommon 1.0.0
dotnet add package WPFCommon --version 1.0.0
NuGet\Install-Package WPFCommon -Version 1.0.0
<PackageReference Include="WPFCommon" Version="1.0.0" />
<PackageVersion Include="WPFCommon" Version="1.0.0" />
<PackageReference Include="WPFCommon" />
paket add WPFCommon --version 1.0.0
#r "nuget: WPFCommon, 1.0.0"
#:package WPFCommon@1.0.0
#addin nuget:?package=WPFCommon&version=1.0.0
#tool nuget:?package=WPFCommon&version=1.0.0
WPFCommon
A lightweight utility library that simplifies command handling and ViewModel patterns in WPF applications, following MVVM principles.
WPFCommon provides:
- A base
ViewModelBasewith built‑inINotifyPropertyChangedsupport - A reusable
DelegateCommandimplementation - A
CommandViewModelabstraction to easily bind commands, visibility, and enabled state to the UI
This package is designed to reduce boilerplate code and make WPF command usage more readable, consistent, and maintainable.
✨ Features
- ✅
ViewModelBasewith automatic property change notification - ✅ Centralized property storage using
Get<T>() / Set<T>() - ✅
DelegateCommandimplementation withCanExecutesupport - ✅ Automatic UI refresh via
CommandManager.RequerySuggested - ✅
CommandViewModelfor binding commands, tooltips, visibility, and enabled state - ✅ Fully compatible with MVVM
📦 Installation
Install from NuGet:
dotnet add package WPFCommon
Or via NuGet Package Manager in Visual Studio:
WPFCommon
🧱 Core Components
1️⃣ ViewModelBase
ViewModelBase is the foundation for all ViewModels.
public class MyViewModel : ViewModelBase
{
public string Title
{
get => Get<string>() ?? string.Empty;
set => Set(value);
}
}
✔ Implements INotifyPropertyChanged
✔ Automatically updates bindings
✔ Refreshes commands when properties change
2️⃣ DelegateCommand
A simple and reusable ICommand implementation.
public DelegateCommand SaveCommand { get; }
public MyViewModel()
{
SaveCommand = new DelegateCommand(_ => Save(), _ => CanSave());
}
private void Save() { /* logic */ }
private bool CanSave() => true;
✔ Supports CanExecute
✔ Automatically raises CanExecuteChanged
3️⃣ CommandViewModel
CommandViewModel encapsulates everything needed to represent a command in the UI.
new CommandViewModel(
"Save",
new DelegateCommand(_ => Save()),
"Save current data",
Visibility.Visible,
true
)
Properties included:
CommandIsEnabledCommandVisibilityDisplayNameDisplayToolTip
🚀 Example (from included WPF demo)
ViewModel
public class FirstTabViewModel : ViewModelBase
{
public IEnumerable<CommandViewModel> Commands { get; }
public FirstTabViewModel()
{
Commands = new List<CommandViewModel>
{
new CommandViewModel(
"Only text and action",
new DelegateCommand(_ => Click1())
),
new CommandViewModel(
"Text, tooltip and action",
new DelegateCommand(_ => Click2()),
"Tool Tip Button"
),
new CommandViewModel(
"Disabled Button",
new DelegateCommand(_ => Click3()),
"Disabled",
null,
false
)
};
}
private void Click1() => MessageBox.Show("Button 1 clicked");
private void Click2() => MessageBox.Show("Button 2 clicked");
private void Click3() { }
}
XAML Binding
<Button
Content="{Binding DisplayName}"
Command="{Binding Command}"
IsEnabled="{Binding IsEnabled}"
Visibility="{Binding CommandVisibility}" />
This allows you to dynamically control UI behavior entirely from the ViewModel.
🧠 Why use WPFCommon?
- Avoid repetitive
INotifyPropertyChangedcode - Centralize command logic
- Improve ViewModel readability
- Keep UI logic out of code‑behind
Ideal for:
- Small to medium WPF projects
- MVVM‑based applications
- Teams looking for consistency
📄 License
MIT License
👤 Author
Carlos Adrián Cervantes Durán GitHub: https://github.com/IngNefly
🔧 Notes
- Target framework: .NET 8.0 (Windows)
- Requires WPF (
UseWPF=true) - Designed for extensibility
⭐ If you find this package useful, feel free to star the repository or contribute!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net8.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 140 | 1/28/2026 |