configuring-avalonia-dependency-injection

Configure dependency injection for AvaloniaUI projects using GenericHost patterns.

40|5|Updated Dec 9, 2025
One-click install
npx skills add https://github.com/christian289/dotnet-with-claudecode --skill configuring-avalonia-dependency-injection
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: configuring-avalonia-dependency-injection
Source: https://github.com/christian289/dotnet-with-claudecode/tree/main/.claude/skills/configuring-avalonia-dependency-injection
Command: npx skills add https://github.com/christian289/dotnet-with-claudecode --skill configuring-avalonia-dependency-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Avalonia apps often require a robust DI setup and a GenericHost-based lifecycle. This skill shows how to bootstrap a DI container, register services, and wire up views and view models for AvaloniaUI projects.

Core Features & Use Cases

  • Provides a ready-to-use pattern for creating a GenericHost in Avalonia apps.
  • Demonstrates registering services, view models, and main views for MVVM architectures.
  • Useful whenever you want consistent DI, testability, and lifecycle management across AvaloniaUI projects.

Quick Start

Configure a GenericHost, register services, and bootstrap the main window.

Frequently Asked Questions about configuring-avalonia-dependency-injection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure dependency injection in an Avalonia app using GenericHost?▼

To configure dependency injection in an Avalonia app, you use Microsoft.Extensions.Hosting APIs to create a GenericHost, register services, and wire up the main window for binding. This provides a ready-to-use pattern for consistent DI and lifecycle management.

What is the best way to register view models and services for AvaloniaUI MVVM architectures?▼

The best way to register view models and services for AvaloniaUI is by configuring a GenericHost. This approach demonstrates registering services, view models, and main views, ensuring testability and consistent lifecycle management across your applications.

Can I use Microsoft.Extensions.DependencyInjection with AvaloniaUI projects?▼

Yes, you can use Microsoft.Extensions.DependencyInjection with AvaloniaUI projects. The setup requires these hosting APIs to create a GenericHost, allowing you to bootstrap a DI container, register services, and configure the main window binding.

Why use GenericHost for lifecycle management in Avalonia applications?▼

You use GenericHost for lifecycle management in Avalonia applications to achieve consistent dependency injection and testability. It allows you to bootstrap a DI container that manages the app lifecycle, registering necessary services and views for MVVM architectures.

How do I bootstrap a main window with dependency injection in Avalonia?▼

To bootstrap a main window with dependency injection in Avalonia, you configure a GenericHost and register your services and view models. This setup wires up the views and view models, configuring the MainWindow binding through the DI container.