Skills2026年5月16日·1 分钟阅读

.NET MAUI — Build Native Cross-Platform Apps with C# and XAML

Create native mobile and desktop applications for Android, iOS, macOS, and Windows from a single C# and XAML codebase. .NET MAUI is the evolution of Xamarin.Forms, providing a unified framework for multi-platform development.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
.NET MAUI Overview
通用 CLI 安装命令
npx tokrepo install 01e879c4-5143-11f1-9bc6-00163e2b0d79

Introduction

.NET Multi-platform App UI (MAUI) is Microsoft's framework for building native cross-platform applications with C# and XAML. It unifies Android, iOS, macOS, and Windows development into a single project structure, replacing Xamarin.Forms with a modernized architecture built on .NET 6+.

What .NET MAUI Does

  • Enables single-project development targeting Android, iOS, macOS, and Windows
  • Provides native UI controls that map to platform-specific widgets
  • Offers hot reload for both XAML and C# during development
  • Includes a dependency injection container and app lifecycle management
  • Supports Blazor Hybrid for embedding web UI within native app shells

Architecture Overview

MAUI uses a handler architecture where each cross-platform control maps to a platform-specific native control through handler classes. The framework runs on .NET runtime with platform-specific workloads (Android uses Mono, iOS uses AOT compilation, Windows uses WinUI 3, macOS uses Mac Catalyst). A single .csproj file manages all platform targets with conditional compilation and platform-specific resource management.

Self-Hosting & Configuration

  • Install the .NET SDK with MAUI workload via dotnet workload install maui
  • Configure target frameworks in the .csproj file (net8.0-android, net8.0-ios, etc.)
  • Manage app identity and permissions in Platforms/ folder per target
  • Set up resources (fonts, images, splash screens) in the shared Resources/ directory
  • Use MauiProgram.cs to configure services, fonts, and platform-specific handlers

Key Features

  • Single project structure eliminates the need for separate platform projects
  • Blazor Hybrid support lets you reuse web components inside native apps
  • Native performance with platform-specific rendering (no WebView overhead)
  • Extensive community ecosystem of controls and libraries via NuGet
  • Visual Studio integration with designers, profilers, and device emulators

Comparison with Similar Tools

  • Xamarin.Forms — predecessor to MAUI; MAUI modernizes the architecture with handlers and single-project structure
  • Flutter — uses Dart with custom rendering; MAUI uses C# with native platform controls
  • React Native — JavaScript with native views; MAUI targets developers already in the .NET ecosystem
  • Uno Platform — also targets multiple platforms with C#/XAML but renders via SkiaSharp; MAUI uses native controls
  • Avalonia UI — cross-platform .NET UI with custom rendering; MAUI provides native look and feel per platform

FAQ

Q: Is .NET MAUI the replacement for Xamarin? A: Yes. Microsoft officially transitioned from Xamarin.Forms to .NET MAUI. Xamarin support ended in May 2024 and MAUI is the recommended migration path.

Q: Can I use .NET MAUI on Linux? A: Linux is not officially supported as a deployment target. Community efforts exist but Microsoft focuses on Android, iOS, macOS, and Windows.

Q: Does MAUI support hot reload? A: Yes. Both XAML Hot Reload and .NET Hot Reload are supported, allowing you to see UI and logic changes without restarting the app during debugging.

Q: Can I mix Blazor web components with native MAUI views? A: Yes. Blazor Hybrid lets you host Razor components inside a BlazorWebView control within your MAUI app, combining web and native UI in one application.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产