设计与多媒体

winui-app

试用

用 C# 和 Windows App SDK 引导、搭建并验证 WinUI 3 桌面应用。

它能做什么

面向 WinUI 3 与 Windows App SDK 的开发任务,参考 Microsoft Learn 官方文档、WinUI Gallery 示例、WindowsAppSDK-Samples 以及 CommunityToolkit 组件。技能会先把任务归类为环境准备、新项目搭建、设计、实现、评审或排错,再运行内置的 WinGet 配置和 `dotnet new winui` 脚手架,只按需加载对应的参考文件。它会明确选择 packaged 或 unpackaged 模型,编译后启动应用,直到看到真实的顶层窗口或正确的窗口标题等客观信号才返回控制权。参考文件覆盖环境审计、XAML 编译器故障的回退恢复、Shell/导航/多窗口、控件与自适应布局、Mica 与主题、辅助功能、性能、CommunityToolkit、生命周期/通知/部署以及评审清单。

什么时候用它

  • 为 WinUI 开发审计并修复开发机环境
  • 脚手架搭建一个全新的 packaged 或 unpackaged WinUI 3 项目
  • 从 MSB3073 等 XAML 编译器错误中恢复
  • 选择 Shell、导航、主题或 CommunityToolkit 方案

技能文档

WinUI App

Use this skill for WinUI 3 and Windows App SDK work that needs grounded setup guidance, app bootstrap, modern Windows UX decisions, or concrete implementation patterns.

Required Flow

  1. Classify the task as environment/setup, new-app bootstrap, design, implementation, review, or troubleshooting.
  2. If the task is about preparing a machine for WinUI, auditing readiness, or creating a brand new app, start with the bundled setup-and-scaffold flow in this skill before broader design, implementation, or troubleshooting work:
    • Pick the app name when the request is for a new app.
    • Use the exact name the user gave when it is already a safe folder name.
    • If the user did not give a name, derive a short PascalCase name from the request and state what you chose.
    • Create the project in the user's current workspace unless they asked for another location.
    • Do not use --force unless the user explicitly asked to overwrite existing files.
    • Run the bundled WinGet configuration from the skill directory so the relative path stays exactly config.yaml:
winget configure -f config.yaml --accept-configuration-agreements --disable-interactivity
  • Treat the configuration as intended to enable Developer Mode, install or update Visual Studio Community 2026, and install the Managed Desktop, Universal, and Windows App SDK C# components needed for WinUI development.
  • Assess the configuration result before continuing. Continue on success. If it fails, inspect the output instead of guessing. If the winui template is already available and the toolchain is usable, note the partial failure and continue. If prerequisites are still missing, stop and report the blocker clearly.
  • Verify the template is available before scaffolding:
dotnet new list winui
  • For diagnostics-only environment requests, explain that the bundled bootstrap may change the machine and get confirmation before running it. If the user declines changes, use the manual verification guidance in references/foundation-environment-audit-and-remediation.md and summarize readiness under present, missing, uncertain, and recommended optional tools.
  • For a brand new app, scaffold with dotnet new winui -o . Add template options only when the user asked for them. Supported options: -f|--framework net10.0|net9.0|net8.0, -slnx|--use-slnx, -cpm|--central-pkg-mgmt, -mvvm|--use-mvvm, -imt|--include-mvvm-toolkit, -un|--unpackaged, -nsf|--no-solution-file, --force. Do not invent unsupported flags. If the user asks for packaged behavior, pass --unpackaged false. Otherwise keep the template default.
  • Verify a new scaffold by confirming the expected project file exists and running dotnet build against the generated .csproj.
  • Launch a newly scaffolded app through the correct path for its actual packaging model and confirm there is a real top-level window instead of relying only on the launcher process exit code.
  1. Read references/_sections.md, then load only the reference files that match the task.
  2. Make the packaging model explicit before creating or refactoring the app. Default to packaged for Store-like product workflows and Visual Studio deploy/F5 flows. Default to unpackaged when the user expects repeatable CLI build-and-run loops or direct .exe launches after each change.
  3. When the task is an opaque XAML compiler failure such as MSB3073 or XamlCompiler.exe, read references/foundation-template-first-recovery.md and simplify back toward the current dotnet new winui scaffold for the chosen packaging model before inventing custom recovery structure.
  4. For any work that creates or changes a WinUI app, make a complete but minimal edit set, then build the app and run it before responding to the user. Do this by default even when the user did not explicitly ask for verification. If a running app instance locks the output while more work remains, stop it, rebuild, relaunch, and continue verification. When the work is complete and launch verification succeeds, leave the final verified app instance running for the user unless they explicitly asked you not to.
  5. Treat launch verification as incomplete until the app shows objective success signals such as a responsive top-level window, expected window title, or other clear startup behavior. A spawned process by itself is not enough.
  6. Prefer Microsoft Learn for requirements, API expectations, and platform guidance.
  7. Prefer WinUI Gallery for concrete control usage, shell composition, and design details.
  8. Prefer WindowsAppSDK-Samples for scenario-level APIs such as windowing, lifecycle, notifications, deployment, and custom controls.
  9. Build toward WinUI and Fluent guidance first. Treat native WinUI shells, controls, interactions, and control chrome as the default implementation path.
  10. For grouped command surfaces such as document actions, editor formatting, view toggles, or page-level toolbars, favor a native CommandBar or other stock WinUI command surface before building a custom row with Grid, StackPanel, Border, or ad hoc button groupings.
  11. Do not invent app-specific controls, bespoke component libraries, or custom chrome to replace stock WinUI behavior unless the user explicitly asks for that customization, the existing product design system already requires it, or a verified platform gap leaves no clean native option.
  12. When customization is needed, first compose, template, or restyle built-in WinUI controls and system resources before adding CommunityToolkit dependencies or authoring a new custom control.
  13. Use CommunityToolkit only when built-in WinUI controls or helpers do not cover the need cleanly.
  14. Support both light and dark mode by default. Treat single-theme output as an exception that requires an explicit user request or an existing product constraint.
  15. Use theme-aware resources, system brushes, and WinUI styling hooks instead of hard-coded light-only or dark-only colors when building or revising UI.
  16. Make scroll ownership explicit for collection layouts. When a page already scrolls vertically, do not assume a nested GridView or other scroll-owning collection will still render a horizontal poster rail correctly.
  17. Do not add extra Border wrappers around sections, lists, or cards unless the border is doing distinct work that the contained control or parent surface does not already provide. Avoid "double-card" compositions where a section Border wraps child items that already render as cards.
  18. Treat responsiveness as a shell-plus-page problem, not only a control-resize problem. Plan explicit wide, medium, and phone-width behavior for navigation, padding, content density, and footer/tool regions, and simplify or hide nonessential UI as width shrinks.

Common Routes

RequestRead first
Check whether this PC can build WinUI appsreferences/foundation-environment-audit-and-remediation.md
Install missing WinUI prerequisitesreferences/foundation-environment-audit-and-remediation.md
Start a new packaged or unpackaged appreferences/foundation-setup-and-project-selection.md
Recover from opaque XAML compiler or startup failures while staying anchored to the template scaffoldreferences/foundation-template-first-recovery.md
Build, run, or verify that a WinUI app actually launchedreferences/build-run-and-launch-verification.md
Review app structure, pages, resources, and bindingsreferences/foundation-winui-app-structure.md
Choose shell, navigation, title bar, or multi-window patternsreferences/shell-navigation-and-windowing.md
Choose controls or responsive layout patternsreferences/controls-layout-and-adaptive-ui.md
Apply Mica, theming, typography, icons, or Fluent stylingreferences/styling-theming-materials-and-icons.md
Improve accessibility, keyboarding, or localizationreferences/accessibility-input-and-localization.md
Diagnose responsiveness or UI-thread performancereferences/performance-diagnostics-and-responsiveness.md
Decide whether to use CommunityToolkitreferences/community-toolkit-controls-and-helpers.md
Handle lifecycle, notifications, or deploymentreferences/windows-app-sdk-lifecycle-notifications-and-deployment.md
Run a review checklistreferences/testing-debugging-and-review-checklists.md

Environment Rules

  • Do not guess whether the machine is ready for WinUI development. Verify it.
  • Use the bundled setup-and-scaffold flow in this skill for fresh setup, remediation, and first-project scaffolding instead of delegating to another skill.
  • Treat config.yaml in this skill directory as the bundled bootstrap source of truth.
  • Treat uncertain environment signals as uncertain, not as success.
  • If the task is audit-only and the user declines machine changes, use the manual verification guidance in references/foundation-environment-audit-and-remediation.md and keep uncertain signals explicit instead of implying success.
  • If config.yaml is missing, say so clearly and fall back to the official Microsoft workflow instead of pretending the bundled path exists.
  • Keep environment readiness, packaging choice, and application startup verification as separate checks. Passing one does not prove the others.
  • Fail closed on ambiguous launch results. If the app did not clearly open, keep debugging.
  • After creating or editing a WinUI app, do not stop at a successful build. Launch the app, confirm objective startup behavior, and leave the final verified app instance running before returning control to the user unless they explicitly say not to run it.

Reference Rules

  • Keep C# as the primary path. Mention C++ or C++/WinRT only when the difference is material.
  • Preserve the conventions of an existing codebase instead of forcing a generic sample structure onto it.
  • Treat WinUI design guidance and native controls as the baseline. Do not drift into bespoke component systems or app-specific replacements for standard controls unless the user explicitly requests them or the existing codebase already depends on them.
  • Support light and dark mode by default for app UI work unless the user explicitly asks for a single-theme result or the product already enforces one.
  • Favor built-in WinUI controls and system styling hooks before adding CommunityToolkit dependencies, custom controls, or app-specific surface systems.
  • Put detailed control, theming, shell, scrolling, responsiveness, packaging, and recovery guidance in the matching reference files instead of duplicating those rules here.

常见问题

这个技能会真的在我的机器上安装 WinUI 开发依赖吗?
用于环境准备或新建项目时会的。它会运行内置的 `winget configure -f config.yaml`,目标是开启开发者模式并安装带 Managed Desktop、Universal 与 Windows App SDK C# 组件的 Visual Studio Community 2026,然后再校验 `dotnet new winui` 模板是否可用。仅做诊断时,不会主动修改机器,会先确认后再汇总就绪情况。
它会搭建 packaged 还是 unpackaged 的 WinUI 应用?
脚手架前会先明确打包模型。默认 packaged,适合类 Store 工作流和 Visual Studio F5;默认 unpackaged,适合可重复的 CLI 构建运行循环或每次改动后直接启动 `.exe`。技能只传入你要求的模板参数,不会捏造不支持的标志。
它如何确认应用真的启动成功了?
编译成功不等于启动成功。它会按打包模型对应的方式启动应用,只有观察到响应正常的顶层窗口或符合预期的窗口标题等客观信号,才算通过验证。除非你明确要求不运行,否则会把验证通过的实例保持运行再交还给你。
它的设计建议和 API 资料从哪里来?
平台要求与 API 优先看 Microsoft Learn,控件用法与 Fluent 设计细节优先看 WinUI Gallery,窗口、生命周期、通知、部署等场景级 API 优先看 WindowsAppSDK-Samples。仅在内置 WinUI 控件无法满足需求时,才会引入 CommunityToolkit。

相关技能

docx

官方

用脚本创建、读取和编辑 Word .docx 与 .dotx 文件。

作者 Anthropic180.0k 星标

用文档优先的流程搭建 ChatGPT Apps SDK 项目,产出工具规划、MCP 服务端与 Widget 脚手架。

作者 OpenAI27.9k 星标

按正确顺序在 Figma 中搭建与代码对齐的完整设计系统,覆盖变量、组件与主题。

作者 OpenAI27.9k 星标

hatch-pet

官方

从文字描述、参考图或品牌线索生成 Codex 兼容的动画宠物与 8x9 雪碧图集。

作者 OpenAI27.9k 星标

把 Figma 设计稿转成与原图视觉一致的页面代码。

作者 OpenAI27.9k 星标

OpenAI 的更多技能

浏览全部技能

用文档优先的流程搭建 ChatGPT Apps SDK 项目,产出工具规划、MCP 服务端与 Widget 脚手架。

作者 OpenAI27.9k 星标

按正确顺序在 Figma 中搭建与代码对齐的完整设计系统,覆盖变量、组件与主题。

作者 OpenAI27.9k 星标

figma-use

官方

通过智能体在 Figma 文件中安全、增量地执行 Plugin API JavaScript。

作者 OpenAI27.9k 星标

hatch-pet

官方

从文字描述、参考图或品牌线索生成 Codex 兼容的动画宠物与 8x9 雪碧图集。

作者 OpenAI27.9k 星标

imagegen

官方

通过内置 imagegen 工具生成或编辑位图图像,CLI 兜底模式仅在用户明确要求时启用。

作者 OpenAI27.9k 星标

从 OpenAI 开发者文档获取带引用和来源路径的权威、实时答案。

作者 OpenAI27.9k 星标