Oakrey.ViewModels
3.0.0
dotnet add package Oakrey.ViewModels --version 3.0.0
NuGet\Install-Package Oakrey.ViewModels -Version 3.0.0
<PackageReference Include="Oakrey.ViewModels" Version="3.0.0" />
<PackageVersion Include="Oakrey.ViewModels" Version="3.0.0" />
<PackageReference Include="Oakrey.ViewModels" />
paket add Oakrey.ViewModels --version 3.0.0
#r "nuget: Oakrey.ViewModels, 3.0.0"
#:package Oakrey.ViewModels@3.0.0
#addin nuget:?package=Oakrey.ViewModels&version=3.0.0
#tool nuget:?package=Oakrey.ViewModels&version=3.0.0
Oakrey.ViewModels
Oakrey.ViewModels provides small MVVM helpers for WPF applications: base view model classes, relay commands, observable collections, dispatcher-aware events, and hyperlink commands.
Features
ViewModelBaseimplementsINotifyPropertyChangedand includesSetPropertyhelpers for concise property setters.DisposableViewModelBasemanages subscriptions through aCompositeDisposableand exposes disposal guards for derived view models.RelayCommand,RelayCommand<T>, andCommandBasesupport WPF command binding and manualRaiseCanExecuteChangednotifications.LazyCommandFactorycreates lazily initialized commands for view models that should defer command allocation.AsyncObservableCollection<T>provides snapshot-based enumeration and dispatcher-aware collection/property change notifications.ObservableQueue<T>raises collection/property notifications and can safely operate without a current WPFApplicationdispatcher.- Hyperlink helpers validate URI schemes before opening links through the shell.
Installation
dotnet add package Oakrey.ViewModels
Package Manager Console:
Install-Package Oakrey.ViewModels
Examples
Use SetProperty in a view model:
public sealed class UserViewModel : ViewModelBase
{
private string name = string.Empty;
public string Name
{
get => name;
set => SetProperty(ref name, value);
}
}
Create a command:
public ICommand SaveCommand { get; } = new RelayCommand(_ => Save(), _ => CanSave);
Use a typed command:
public ICommand OpenCommand { get; } = new RelayCommand<string>(Open, path => !string.IsNullOrWhiteSpace(path));
Create a dispatcher-aware observable queue:
ObservableQueue<string> queue = new();
queue.Enqueue("Ready");
if (queue.TryDequeue(out string? message))
{
Console.WriteLine(message);
}
Notes
RelayCommand<T>.CanExecute(object?)returnsfalsefor invalid command parameters;Execute(object?)still throws to surface binding/configuration mistakes.HyperlinkHelperallowshttp,https, andmailtolinks by default.ObservableQueue<T>falls back to direct invocation when no WPF application dispatcher is available, which makes it easier to use in tests and non-visual code.
Requirements
- .NET 10 Windows target (
net10.0-windows) - WPF enabled project
Project Information
- Author: Oakrey
- Company: Oakrey (Website)
- License: MIT
- Repository: Git Repository
- Project URL: NuGet
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
-
net10.0-windows7.0
- System.Reactive (>= 6.1.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Oakrey.ViewModels:
| Package | Downloads |
|---|---|
|
Oakrey.Applications.About
A WPF/.NET library providing an About dialog with application name and version display, loaded assembly/module version listing, RTF EULA rendering, and a Report Issue form with log folder access. |
|
|
Oakrey.Applications.Terminals
A WPF/MVVM .NET library for building terminal-like interfaces. Provides a generic TerminalViewModel base with reactive message collections (System.Reactive), navigable command history, sort and display settings, file export, and built-in Oakrey.Log and Oakrey.Telemetry integration. |
|
|
Oakrey.DevOps.UI
Package contains: UI models for managing Azure DevOps work items, including BugModel and FeatureModel. Provides commands for submitting bugs and feature requests with support for attaching logs and tags. |
|
|
Oakrey.Interactions
The Oakrey.Interactions library provides a framework for managing user interactions in .NET applications. It supports various question and response types, enabling developers to create interactive workflows with ease. |
|
|
Oakrey.Applications.Abstractions
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.