microsoft/winappcli/winui-wpf-migration
Claude Code and agent skill by microsoft/winappcli
- vendor
Checking that the SKILL.md file is still in the repository.
Migrate or port a WPF app to WinUI 3: namespaces (System.Windows to Microsoft.UI.Xaml), control mapping (DataGrid, WrapPanel, TabControl), Dispatcher to DispatcherQueue, imaging, MVVM with CommunityToolkit.Mvvm, ThemeResource. Use when converting WPF code or fixing migration build errors.
Install
npx vskill@latest install microsoft/winappcli/winui-wpf-migrationSKILL.md
The same SKILL.md was published earlier as microsoft/winappcli/winui-wpf-migration.
WPF to WinUI 3 Migration
Port WPF code to WinUI 3 while preserving the application's behavior, deployment, stored data, and external contracts.
When to Use
- Convert WPF XAML, controls, bindings, or
System.Windows.*APIs to WinUI 3. - Port dispatcher calls, windows, dialogs, file pickers, or imaging code.
- Adapt observable properties, commands, resources, and tests during a WPF migration.
- Fix project, runtime, installer, or signing failures caused by that migration.
Use winui-design for control samples, winui-dev-workflow for project setup and build/run commands, and winui-packaging when packaging is in scope. Keep the target project's versions, deployment, and required behavior when using those workflows.
Migration Sequence
Port bounded groups of files in dependency order:
- Project files — prepare the WinUI target, package references, XAML/resource items, native references, and assets. Keep assembly names and deployment settings required by existing callers.
- Models and shared logic — remove UI-framework dependencies from reusable logic. Share CLI/UI behavior through a library when needed, without executable-to-executable project references.
- MVVM — replace custom observable/command infrastructure with CommunityToolkit.Mvvm. Preserve setter transformations, defaults, serialization attributes, notifications, and command behavior.
- Resource strings — migrate the application's
.resxstrings and their code/XAML consumers to.resw, connect the PRI resource index and accessor, and keep stable keys. - Services and imaging — replace WPF types and propagate asynchronous APIs through callers. Preserve codec, metadata, cancellation, and error behavior.
- View models — move UI updates onto their owning dispatcher queue and adapt binding/command notifications.
- Views and pages — start with leaf views. Port markup, styles, converters, templates, keyboard behavior, and accessibility.
- Main view and shell — integrate the converted views, navigation, windows, and owner-dependent dialogs/pickers.
- Application startup — merge initialization, resources, activation, and cleanup into the WinUI lifecycle.
- Existing installer, packaging, or signing steps — update only the affected steps if the port changes the files they consume or when those files are ready.
- Tests — adapt async calls, resource access, pixel/metadata assertions, settings fixtures, and integration scenarios.
Compile each migrated group and run its relevant tests when the repository permits those checks. Follow restrictions that defer builds to final acceptance, and keep failures attributable to the changed group.
Migration Rules
Projects and application code
Check uncertain replacement APIs against the restored WinUI app, not the machine SDK. From the target app's project directory, search for the type, then inspect the member on the intended type (see winui-design):
- Merge into the target's
App.xamlandApp.xaml.cs; preserve generated startup and initialization that the target SDK needs. - Remove WPF-only dependencies and project items once their callers have been ported. Do not add
UseWPFor a WPF framework reference to the WinUI application to conceal an incomplete conversion. - Keep the existing
Package.appxmanifestfor packaged apps. ChangeWindowsPackageType,WindowsAppSDKSelfContained,SelfContained, or package identity only as part of the chosen deployment configuration. - Keep reusable logic out of executable project references; check unexpected copied executables, dependency files, and runtime configuration files in the output.
- Use CommunityToolkit.Mvvm for migrated observable properties and commands. Prefer source-generated partial properties with a supported compiler and Toolkit version.
- Keep the way the app creates services. If it already uses dependency injection, register migrated services there; do not add a container for the port.
- Use a plain
Windowfor top-level windows. Set its size withAppWindow; useOverlappedPresenterto control whether users can resize it or it stays on top. If the project already uses WinUIEx, keep itsWindowExbase. - Use
ContentDialogfor in-app dialogs andFrame/Pagefor sub-views. Reserve separate windows for distinct top-level surfaces. - Preserve JSON names, enum values, defaults, resource keys, CLI options, and IPC/COM contracts.
XAML and resources
- Replace
clr-namespace:withusing:, and map unsupported markup individually.x:DataTypeenables typed templates but does not reproduce WPF's implicit template selection. - Use
ThemeResourcefor theme-dependent resources,StaticResourcefor fixed resources, and binding/code for other dynamic values. - Replace WPF triggers with the appropriate visual states, bindings, or WinUI behaviors. Put state groups on a
Page/UserControlcontent root or a control-template root. - Use direct Boolean
x:Bind, existing control states, or suitable Toolkit converters before copying a WPF converter. Preserve the intended conversion and its inverse. - Prefer
x:Bindfor new and migrated views with known types. Use classicBindingwhere the source must be resolved through runtimeDataContext. - Audit binding source, effective mode, and update timing. WPF editable properties that bind two-way by default need explicit
Mode=TwoWayin WinUI. - Put
DataContextand element resources on the hosted view/root element. A WinUIWindowdoes not expose the WPF equivalents. - Preserve valid
PreviewKeyDown/PreviewKeyUphandlers; redesign WPF mouse preview events according to their required behavior. - Keep resource lookup out of early static initialization paths used by models, CLI entry points, or tests.
Threading and imaging
- Map
Dispatcher.Invokeby its completion and exception semantics.DispatcherQueue.TryEnqueueonly reports whether work was accepted. - Track the window/queue that owns UI state. Use that window's loaded
XamlRootfor dialogs and its HWND orWindowIdfor the selected picker API. - Keep image processing separate from XAML image sources. Validate pixel format, alpha, dimensions, orientation, codec options, and stream ownership.
- Preserve all required frames and metadata when replacing WPF encoders; a successful encode alone does not establish equivalent output.
Common Migration Failures
| Symptom | What to check | |
|---|---|---|
| A WinUI project still needs WPF assemblies | Check callers, resource items, generated files, and shared-library dependencies for WPF-only types. A System.Windows name alone is not a failure: System.Windows.Input.ICommand is valid in WinUI. | |
| Startup reports a Windows App SDK runtime/COM activation error | Launch the project with winapp run .\MyApp.csproj --detach --json first (see winui-dev-workflow). Starting a packaged app's .exe directly skips package activation. If project launch still fails, check package identity, runtime deployment, architecture, and initialization. | |
| A window's bindings or resources do not resolve | Move view state and resources to the hosted view/root and check the binding source. | |
| Edited text does not reach the view model | Check explicit Mode=TwoWay, update timing, and notifications. | |
| A dialog or picker opens without the correct owner | Supply the owning loaded XamlRoot, HWND, or WindowId required by that API. | |
| Localized strings fail during startup or tests | Check PRI generation/name, resource-map lookup, initialization timing, and the test resource accessor. | |
| A build script works from the solution but not from the project | Check the project-relative build paths. | |
| Image quality, dimensions, or tests change | Check codec options and types, pixel/alpha representation, integer widths, and frame/metadata handling. |
Detailed References
Read the reference that matches the current phase:
- Project and Application Migration — project items, MVVM, localization, installer/build changes, tests, and compatibility.
- Namespace and API Mapping — namespaces, types, controls, properties, packages, and interop.
- XAML Migration — markup, binding, converters, templates, styles, and resource syntax.
- Threading and Windowing — queue semantics, window sizing/lifecycle, dialogs, pickers, and custom entry points.
- Imaging Migration — streams, codecs, options, multi-frame operations, metadata, and image tests.
Completion Checklist
- [ ] The WinUI application's project items and dependencies reflect the completed conversion.
- [ ] Build and launch the app with project-mode
winapp runby default. If activation depends on a separate packaging project (.wapproj), use that project's existing deployment and launch steps instead. Confirm the expected window opens and responds to input. - [ ] Startup, shutdown, window ownership, dialogs, and pickers preserve the required behavior.
- [ ] Binding updates, commands, themes, localization, keyboard access, and automation remain correct.
- [ ] Settings fixtures, CLI behavior, and both directions of any existing IPC integration remain compatible.
- [ ] If the port affected an existing installer, package, or signing step, its inputs match the actual build/publish output.
- [ ] Tests exercise the same image, resource, and application behavior as before the migration.
- [ ] The intended published output is validated; use
winui-dev-workflowfor Native AOT publish/run steps andwinui-packaging'sreferences/sourcegen-patterns.mdfor trimming/binding/serialization guidance.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 26 Oct 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/winui/agent-plugin/skills/winui-wpf-migration/SKILL.md
Popularity
- Repository stars
- 1,336
- Repository forks
- 90
- 7-day trend score
- 41
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/winappcli/winui-wpf-migration)