What problem does it solve?
The MVVM Toolkit ships no DI container, leaving .NET developers to figure out how to compose ViewModels, services, and IMessenger with Microsoft.Extensions.DependencyInjection on their own. This Skill provides the composition root patterns, lifetime guidance, and injection practices needed to wire a XAML app correctly and avoid service-locator anti-patterns.
Core Features & Use Cases
- Composition Root Setup: Build the service provider once at startup using Host.CreateDefaultBuilder() or a plain ServiceCollection for WPF, WinUI 3, .NET MAUI, Uno, and Avalonia apps.
- Lifetime & Registration Guidance: Choose Singleton, Transient, or Scoped lifetimes for ViewModels and services, register IMessenger once, and use keyed services (.NET 8+) for multiple implementations.
- Testing & Legacy Escape Hatches: Inject fakes through constructors for unit tests, and use Ioc.Default only as a last resort for XAML-instantiated objects.
- Use Case: When starting a new WinUI 3 app, use this Skill to configure the Generic Host, register a singleton ShellViewModel and transient per-page ViewModels, then resolve each page's ViewModel in code-behind without manual construction.
Quick Start
Ask the AI to set up the dependency injection composition root for a new WPF or WinUI app using the MVVM Toolkit with constructor-injected ViewModels.