![]() |
VOOZH | about |
dotnet add package Oakrey.Applications.ViewModels --version 2.0.4
NuGet\Install-Package Oakrey.Applications.ViewModels -Version 2.0.4
<PackageReference Include="Oakrey.Applications.ViewModels" Version="2.0.4" />
<PackageVersion Include="Oakrey.Applications.ViewModels" Version="2.0.4" />Directory.Packages.props
<PackageReference Include="Oakrey.Applications.ViewModels" />Project file
paket add Oakrey.Applications.ViewModels --version 2.0.4
#r "nuget: Oakrey.Applications.ViewModels, 2.0.4"
#:package Oakrey.Applications.ViewModels@2.0.4
#addin nuget:?package=Oakrey.Applications.ViewModels&version=2.0.4Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.ViewModels&version=2.0.4Install as a Cake Tool
A .NET library that removes manual DI wiring for ViewModels in MVVM applications.
Mark a ViewModel class with the appropriate lifetime interface and call a single
IServiceCollection extension method � the library discovers and registers all
eligible types automatically via reflection.
IAutoConfigurable implementors at startup.IServiceCollection extension method: RegisterAutoConfigurables.// Marker interfaces � implement one to opt a ViewModel into auto-registration
IAutoConfigurable // transient (default)
ITransientAutoConfigurable // transient (explicit)
IScopedAutoConfigurable // scoped
ISingletonAutoConfigurable // singleton
// IServiceCollection extension
services.RegisterAutoConfigurables();
// Discovery helper (optional, for diagnostics)
List<Type> types = ViewModelsConfiguration.GetAllAutoConfigurables;
| Interface | DI lifetime |
|---|---|
IAutoConfigurable |
Transient |
ITransientAutoConfigurable |
Transient |
IScopedAutoConfigurable |
Scoped |
ISingletonAutoConfigurable |
Singleton |
classDiagram
IAutoConfigurable <|-- ITransientAutoConfigurable
IAutoConfigurable <|-- IScopedAutoConfigurable
IAutoConfigurable <|-- ISingletonAutoConfigurable
ViewModelsConfiguration ..> IAutoConfigurable : discovers
ViewModelsConfiguration ..> IServiceCollection : registers into
Microsoft.Extensions.DependencyInjection.Abstractions (10.0.x)Oakrey.Reflection (2.0.x) � used internally for type discovery.NET CLI
dotnet add package Oakrey.Applications.ViewModels
Package Manager Console
Install-Package Oakrey.Applications.ViewModels
NuGet Package Manager UI
Search for Oakrey.Applications.ViewModels in Visual Studio under
Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
// Singleton � one instance for the application lifetime
internal sealed class MainViewModel : ObservableObject, ISingletonAutoConfigurable
{
public MainViewModel(IMyService service) { }
}
// Transient � new instance every time it is resolved
internal class PromptViewModel : IAutoConfigurable
{
public PromptViewModel(IUserPrompter prompter) { }
}
using Oakrey.Applications.ViewModels;
IServiceCollection services = new ServiceCollection();
services.RegisterAutoConfigurables(); // returns IServiceCollection � fluent chaining is supported
ServiceProvider provider = services.BuildServiceProvider();
MainViewModel vm = provider.GetRequiredService<MainViewModel>();
ViewModelProvider is a WPF MarkupExtension (shipped in Oakrey.Applications) that resolves a ViewModel from the DI container directly in XAML, without any code-behind assignment.
<Window
xmlns:app="clr-namespace:Oakrey.Applications;assembly=Oakrey.Applications"
DataContext="{app:ViewModelProvider viewModelType={x:Type local:MainViewModel}}">
For scoped ViewModels the provider creates a new IServiceScope tied to the FrameworkElement lifetime and disposes it when the element is unloaded.
Oakrey.Reflection and scans all loaded assemblies at the
time RegisterAutoConfigurables is called. Ensure all relevant assemblies are
loaded before calling the extension method.Microsoft.Extensions.DependencyInjection.
ViewModelProvider is the only WPF-specific piece and lives in a separate Oakrey.Applications assembly.GetAllAutoConfigurables returns a List<Type> and can be used at startup to
log or audit which ViewModels were discovered.RegisterAutoConfigurables returns IServiceCollection, so it can be chained fluently with other registration calls.MIT. Copyright (c) Oakrey 2016-present.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 4 NuGet packages that depend on Oakrey.Applications.ViewModels:
| Package | Downloads |
|---|---|
|
Oakrey.Applications.Settings
WPF-only (.NET 10 Windows) library providing ISettingsService with persistent and volatile typed key-value settings, SettingsBase for bindable ViewModelBase-derived settings classes, CallerMemberName key inference, built-in window bounds restore via RestoreBounds, and a one-call ConfigureSettingService DI extension. |
|
|
Oakrey.Applications.Base
A foundational .NET library for building modular WPF applications. Provides application lifecycle management, MVVM ViewModel resolution, structured logging, telemetry, and sequential or parallel service preloading with full unhandled-exception coverage. |
|
|
Oakrey.Applications.ControlObjects
A .NET WPF library for building interactive, validated control objects. Provides a base class hierarchy for reactive sending objects, enable/disable and timer-driven variants, cancelable async operations, device abstraction, multi-key gesture support, and observable collections with automatic JSON persistence. |
|
|
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. |
This package is not used by any popular GitHub repositories.