maui-app-lifecycle
梳理平台差异与保存恢复模式,便于正确处理后台/恢复场景。
提供 .NET MAUI 应用与窗口跨平台生命周期事件、状态保存与恢复的指导。
讲清楚 .NET MAUI 应用和 Window 的跨平台生命周期怎样工作,什么时候保存/恢复状态以及各平台事件如何对应。会在需要处理后台挂起、恢复、窗口激活/停用等场景时用到,帮你选对 OnStopped/OnResumed 等钩子。亮点是把平台差异和状态持久化模式都讲明白,方便统一写跨平台代码。
▸ 展开 SKILL.md 英文原文
.NET MAUI app lifecycle guidance — the four app states, cross-platform Window lifecycle events (Created, Activated, Deactivated, Stopped, Resumed, Destroying), platform-specific lifecycle mapping, backgrounding and resume behavior, and state-preservation patterns. USE FOR: "app lifecycle", "window lifecycle events", "save state on background", "resume app", "OnStopped", "OnResumed", "backgrounding", "deactivated event", "ConfigureLifecycleEvents", "platform lifecycle hooks". DO NOT USE FOR: navigation events (use maui-shell-navigation), dependency injection setup (use maui-dependency-injection), platform API invocation (use conditional compilation and partial classes).
帮我安装这个 skill:https://raw.githubusercontent.com/dotnet/skills/main/plugins/dotnet-maui/skills/maui-app-lifecycle/SKILL.mdcurl -fsSL "https://raw.githubusercontent.com/dotnet/skills/main/plugins/dotnet-maui/skills/maui-app-lifecycle/SKILL.md"# .NET MAUI App Lifecycle Handle application state transitions correctly in .NET MAUI. This skill covers the cross-platform Window lifecycle events, their platform-native mappings, and patterns for preserving state across backgrounding and resume cycles. ## When to Use - Saving or restoring state when the app backgrounds or resumes - Subscribing to Window lifecycle events (Created, Activated, Deactivated, Stopped, Resumed, Destroying) - Hooking into platform-native lifecycle callbacks via `ConfigureLifecycleEvents` - Deciding where to place initialization, teardown, or refresh logic - Understanding the difference between Deactivated and Stopped ## When Not to Use - Page-level navigation