MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Winui3

Winui3是一款code方向的AI技能,核心价值是WinUI 3 and Windows App SDK coding guidelines,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

WinUI 3 and Windows App SDK coding guidelines. Prevents common UWP API misuse, enforces correct XAML namespaces, threading, windowing, and MVVM patterns for desktop Windows apps.

Last verified on: 2026-05-30
mkdir -p ./skills/winui3 && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/winui3/SKILL.md -o ./skills/winui3/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# WinUI 3 / Windows App SDK


Critical Rules — NEVER Use Legacy UWP APIs


These UWP patterns are **wrong** for WinUI 3 desktop apps. Always use the Windows App SDK equivalent.


- **NEVER** use `Windows.UI.Popups.MessageDialog`. Use `ContentDialog` with `XamlRoot` set.

- **NEVER** show a `ContentDialog` without setting `dialog.XamlRoot = this.Content.XamlRoot` first.

- **NEVER** use `CoreDispatcher.RunAsync` or `Dispatcher.RunAsync`. Use `DispatcherQueue.TryEnqueue`.

- **NEVER** use `Window.Current`. Track the main window via a static `App.MainWindow` property.

- **NEVER** use `Windows.UI.Xaml.*` namespaces. Use `Microsoft.UI.Xaml.*`.

- **NEVER** use `Windows.UI.Composition`. Use `Microsoft.UI.Composition`.

- **NEVER** use `Windows.UI.Colors`. Use `Microsoft.UI.Colors`.

- **NEVER** use `ApplicationView` or `CoreWindow` for window management. Use `Microsoft.UI.Windowing.AppWindow`.

- **NEVER** use `CoreApplicationViewTitleBar`. Use `AppWindowTitleBar`.

- **NEVER** use `GetForCurrentView()` patterns (e.g., `UIViewSettings.GetForCurrentView()`). These do not exist in desktop WinUI 3. Use `AppWindow` APIs instead.

- **NEVER** use UWP `PrintManager` directly. Use `IPrintManagerInterop` with a window handle.

- **NEVER** use `DataTransferManager` directly for sharing. Use `IDataTransferManagerInterop` with a window handle.

- **NEVER** use UWP `IBackgroundTask`. Use `Microsoft.Windows.AppLifecycle` activation.

- **NEVER** use `WebAuthenticationBroker`. Use `OAuth2Manager` (Windows App SDK 1.7+).


XAML Patterns


- The default XAML namespace maps to `Microsoft.UI.Xaml`, not `Windows.UI.Xaml`.

- Prefer `{x:Bind}` over `{Binding}` for compiled, type-safe, higher-performance bindings.

- Set `x:DataType` on `DataTemplate` elements when using `{x:Bind}` — this is required for compiled bindings in templates. On Page/UserControl, `x:DataType` enables compile-time binding validation but is not strictly required if the DataContext does not change.

- Use `Mode=OneWay` for dynamic values, `Mode=OneTime` for static, `Mode=TwoWay` only for editable inputs.

- Do not bind static constants — set them directly in XAML.


Threading


- Use `DispatcherQueue.TryEnqueue(() => { ... })` to update UI from background threads.

- `TryEnqueue` returns `bool`, not a `Task` — it is fire-and-forget.

- Check thread access with `DispatcherQueue.HasThreadAccess` before dispatching.

- WinUI 3 uses standard STA (not ASTA). No built-in reentrancy protection — be cautious with async code that pumps messages.


Windowing


- Get the `AppWindow` from a WinUI 3 `Window` via `WindowNative.GetWindowHandle` → `Win32Interop.GetWindowIdFromWindow` → `AppWindow.GetFromWindowId`.

- Use `AppWindow` for resize, move, title, and presenter operations.

- Custom title bar: use `AppWindow.TitleBar` properties, not `CoreApplicationViewTitleBar`.

- Track the main window as `App.MainWindow` (a static property set in `OnLaunched`).


Dialogs and Pickers


- **ContentDialog**: Always set `dialog.XamlRoot = this.Content.XamlRoot` before calling `ShowAsync()`.

- **File/Folder Pickers**: Initialize with `WinRT.Interop.InitializeWithWindow.Initialize(picker, hwnd)` where `hwnd` comes from `WindowNative.GetWindowHandle(App.MainWindow)`.

- **Share/Print**: Use COM interop interfaces (`IDataTransferManagerInterop`, `IPrintManagerInterop`) with window handles.


MVVM and Data Binding


- Prefer `CommunityToolkit.Mvvm` (`[ObservableProperty]`, `[RelayCommand]`) for MVVM infrastructure.

- Use `Microsoft.Extensions.DependencyInjection` for service registration and injection.

- Keep UI (Views) focused on layout and bindings; keep logic in ViewModels and services.

- Use `async`/`await` for I/O and long-running work to keep the UI responsive.


Project Setup


- Target `net10.0-windows10.0.22621.0` (or appropriate TFM for the project's target SDK).

- Set `<UseWinUI>true</UseWinUI>` in the project file.

- Reference the latest stable `Microsoft.WindowsAppSDK` NuGet package.

- Use `System.Text.Json` wi

🎯 Best For

  • UI designers
  • Product designers
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Generating component mockups
  • Creating design system tokens
  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Winui3 to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this work with Figma?

Some design skills integrate with Figma plugins. Check the Works With section for supported tools.

Is Winui3 compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Winui3?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Winui3?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/winui3/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping usability testing

AI-generated designs should be validated with real users before development.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills