Agent skill

mvvm-toolkit-di

Wire CommunityToolkit.Mvvm ViewModels into Microsoft.Extensions.DependencyInjection. Covers the .NET Generic Host composition root, constructor injection, service lifetimes (Singleton / Transient / Scoped), IMessenger registration, resolving ViewModels in Views, keyed services, testing seams, and the legacy Ioc.Default escape hatch. Use across WPF, WinUI 3, .NET MAUI, Uno, and Avalonia.

GitHub68,948★ · +463/wk · 2 repos on radarProfile →
copilotMIT
Install
npx skills add github/awesome-copilot --skill mvvm-toolkit-di --agent copilot

Same command for any agent — swap --agent for claude-code, codex, cursor.

Facts
Files in the skill folder: 2
SKILL.md size: 9 KB
Bundled scripts: none
Path: skills/mvvm-toolkit-di/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 37,432 · +281 this week
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# CommunityToolkit.Mvvm + `Microsoft.Extensions.DependencyInjection` The MVVM Toolkit deliberately ships **no DI container** — it composes with `Microsoft.Extensions.DependencyInjection`, the same container ASP.NET Core, Worker services, and the .NET Generic Host use. > **TL;DR.** Build the service provider once at startup (prefer > `Host.CreateDefaultBuilder()`). Register services and ViewModels. > Inject through constructors. Avoid `Ioc.Default.GetService<T>()` > in user code. --- ## When to use this skill - Standing up the composition root for a new XAML app (WPF, WinUI 3, MAUI, Uno, Avalonia) - Choosing service/VM lifetimes - Wiring `IMessenger` once and injecting it into `ObservableRecipient` ViewModels - Resolving a page's ViewModel without coupling to a service locator - Diagnosing "Unable to resolve service for type X while attempting to activate Y" For source generators and ViewModel patterns see the **`mvvm-toolkit`** skill. For Messenger pub/sub see **`mvvm-toolkit-messenger`**. --- ## Recommended composition root (Generic Host) ```csharp using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using CommunityToolkit.Mvvm.Messaging; public part

What's inside
Steps it walks through
  1. When to use this skill
  2. Recommended composition root (Generic Host)
  3. Without Generic Host
  4. Constructor injection
  5. Lifetimes
  6. Resolving in a View
  7. IMessenger registration
  8. Keyed services (.NET 8+)
  9. Testing seams
  10. Legacy: Ioc.Default
  11. Common pitfalls
  12. References
Ships with 1 file
  • references/dependency-injection.md
More from awesome-copilot
All skills →
About this skill
What does the mvvm-toolkit-di skill do?

Wire CommunityToolkit.Mvvm ViewModels into Microsoft.Extensions.DependencyInjection. Covers the .NET Generic Host composition root, constructor injection, service lifetimes (Singleton / Transient / Scoped), IMessenger registration, resolving ViewModels in Views, keyed services, testing seams, and the legacy Ioc.Default escape hatch. Use across WPF, WinUI 3, .NET MAUI, Uno, and Avalonia.

How do I install it?

Run `npx skills add github/awesome-copilot --skill mvvm-toolkit-di --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From github/awesome-copilot, a repository with 37,432 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going