maui-dependency-injection

Configure dependency injection for MAUI apps in MauiProgram with service lifetimes.

Updated Nov 5, 2025
One-click install
npx skills add https://github.com/mkazimoto/AppMAUICopilot --skill maui-dependency-injection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: maui-dependency-injection
Source: https://github.com/mkazimoto/AppMAUICopilot/tree/main/.github/skills/maui-dependency-injection
Command: npx skills add https://github.com/mkazimoto/AppMAUICopilot --skill maui-dependency-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dependency injection wiring for .NET MAUI projects, enabling centralized service configuration, testability, and scalable architectures.

Core Features & Use Cases

  • Service registration in MauiProgram.cs with proper lifetimes (Singleton, Transient, Scoped) and automatic resolution via Shell navigation.
  • Platform-specific registrations and an interface-first approach to facilitate testing and substitution.
  • Guidance for constructing resilient MAUI apps with DI best practices and common patterns.

Quick Start

Register services in MauiProgram by wiring builder.Services to concrete implementations.

Frequently Asked Questions about maui-dependency-injection

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

FAQPage Schema
How do I configure dependency injection in .NET MAUI for Shell navigation?

Configure dependency injection in .NET MAUI by registering services, view models, and pages in MauiProgram, enabling automatic resolution via Shell navigation. Apply lifetime management and constructor injection to wire view models to pages during navigation.

What is the best way to manage service lifetimes in a MAUI app?

Manage service lifetimes in a MAUI app by applying Singleton, Transient, and Scoped registrations in MauiProgram. Select Singleton for stateful app-wide services, Transient for lightweight stateless components, and Scoped for context-bound operations.

How do I register platform-specific services in MauiProgram?

Register platform-specific services in MauiProgram by wiring builder.Services to concrete implementations. Apply conditional registrations and an interface-first approach to ensure platform-specific dependencies resolve correctly while maintaining testability.

Does dependency injection in MAUI support testing and mock substitutions?

Dependency injection in MAUI supports testing by adopting an interface-first pattern for service registration. Register interfaces rather than concrete implementations to substitute dependencies with mocks during unit testing.

Why does my MAUI Shell navigation fail to resolve view model dependencies?

MAUI Shell navigation fails to resolve view model dependencies when services are not explicitly registered in MauiProgram or lack proper lifetime configuration. Ensure constructor injection requirements are fully wired before invoking Shell navigation.