microsoft/powertoys/wpf-to-winui3-migration
Claude Code and agent skill by microsoft/powertoys
- vendor
Checking that the SKILL.md file is still in the repository.
Guide for migrating PowerToys modules from WPF to WinUI 3 (Windows App SDK). Use when asked to migrate WPF code, convert WPF XAML to WinUI, replace System.Windows namespaces with Microsoft.UI.Xaml, update Dispatcher to DispatcherQueue, replace DynamicResource with ThemeResource, migrate imaging APIs from System.Windows.Media.Imaging to Windows.Graphics.Imaging, convert WPF Window to WinUI Window, migrate .resx to .resw resources, migrate custom Observable/RelayCommand to CommunityToolkit.Mvvm source generators, handle WPF-UI (Lepo) to WinUI native control migration, or fix installer/build pipeline issues after migration. Keywords: WPF, WinUI, WinUI3, migration, porting, convert, namespace, XAML, Dispatcher, DispatcherQueue, imaging, BitmapImage, Window, ContentDialog, ThemeResource, DynamicResource, ResourceLoader, resw, resx, CommunityToolkit, ObservableProperty, WPF-UI, SizeToContent, AppWindow, SoftwareBitmap.
Install
npx vskill@latest install microsoft/powertoys/wpf-to-winui3-migrationSKILL.md
The same SKILL.md was published earlier as microsoft/powertoys/wpf-to-winui3-migration.
WPF to WinUI 3 Migration Skill
Migrate PowerToys modules from WPF (System.Windows.*) to WinUI 3 (Microsoft.UI.Xaml.* / Windows App SDK). Based on patterns validated in the ImageResizer module migration.
When to Use This Skill
- Migrate a PowerToys module from WPF to WinUI 3
- Convert WPF XAML files to WinUI 3 XAML
- Replace
System.Windowsnamespaces withMicrosoft.UI.Xaml - Migrate
Dispatcherusage toDispatcherQueue - Migrate custom
Observable/RelayCommandto CommunityToolkit.Mvvm source generators - Replace WPF-UI (Lepo) controls with native WinUI 3 controls
- Convert imaging code from
System.Windows.Media.ImagingtoWindows.Graphics.Imaging - Handle WPF
Windowvs WinUIWindowdifferences (sizing, positioning, SizeToContent) - Migrate resource files from
.resxto.reswwithResourceLoader - Fix installer/build pipeline issues after WinUI 3 migration
- Update project files, NuGet packages, and signing config
Prerequisites
- Visual Studio 2022 17.4+
- Windows App SDK NuGet package (
Microsoft.WindowsAppSDK) - .NET 8+ with
net8.0-windows10.0.19041.0TFM - Windows 10 1803+ (April 2018 Update or newer)
Migration Strategy
Phase-by-Phase Scope
Work on bounded problems, not the entire codebase at once. Each phase should compile before moving to the next.
- Project file — Update TFM, NuGet packages, set
<UseWinUI>true</UseWinUI> - Data models and business logic — No UI dependencies, migrate first
- MVVM framework — Replace custom Observable/RelayCommand with CommunityToolkit.Mvvm
- Resource strings — Migrate
.resx→.resw, introduceResourceLoaderInstance - Services and utilities — Replace
System.Windowstypes, async-ify imaging code - ViewModels — Update Dispatcher usage, binding patterns
- Views/Pages — Starting from leaf pages with fewest dependencies
- Main page / shell — Last, since it depends on everything
- App.xaml / startup code — Merge carefully (do NOT overwrite WinUI 3 boilerplate)
- Installer & build pipeline — Update WiX, signing, build events
- Tests — Adapt for WinUI 3 runtime, async patterns
Migration Contract: Prohibited Patterns
These rules capture human judgment and must be applied consistently across every file. Do NOT deviate.
Architecture prohibitions:
- Do NOT overwrite `App.xaml` / `App.xaml.cs` — WinUI 3 has different lifecycle boilerplate. Merge resources and init code into the generated WinUI 3 App class.
- Do NOT create Exe→WinExe `ProjectReference` — Extract shared code to a Library project. Causes phantom build artifacts.
- Do NOT instantiate services directly — Use DI and CommunityToolkit.Mvvm patterns.
- Do NOT create a `Window` subclass for every dialog or sub-page — use
ContentDialogfor in-app dialogs andFrame/Pagenavigation for sub-views. SeparateWindowclasses are reserved for distinct top-level surfaces (e.g., FancyZones editor, OOBE). - Do NOT omit `WindowsPackageType=None` and `WindowsAppSDKSelfContained=true` — Both are mandatory in the csproj for every WinUI 3 module in PowerToys. Without them the app crashes at startup with
COMException: ClassFactory cannot supply requested classbecause the WinUI 3 runtime DLLs are not found. - Do NOT default to a bare `Window`, and do NOT hand-write code-behind for windowing that XAML can express — For a top-level window in a WinUI 3 module, use
WinUIEx.WindowExor an existing PowerToys base derived from it (for example,TransparentWindowfor transient overlays).WindowExrestores WPF-likeWindowmembers as XAML properties (MinWidth/MinHeight,Width/Height,IsResizable,IsMaximizable/IsMinimizable,IsTitleBarVisible,IsAlwaysOnTop,IsShownInSwitchers,WindowState,SystemBackdrop) plus helpers (CenterOnScreen(),PersistenceId), so windowing is declared in XAML instead of manualAppWindow/OverlappedPresentercode-behind. This is the established PowerToys convention across ImageResizer, PowerDisplay, Peek, AdvancedPaste, MeasureTool, ShortcutGuide, Settings, Hosts, FileLocksmith, QuickAccess, and other WinUI 3 modules. Only drop to rawAppWindow/presenter code for behaviorWindowExdoes not expose. See Threading and Window Management → WindowEx.
XAML prohibitions:
- Do NOT use `{DynamicResource}` — Replace with
{ThemeResource}(theme-reactive) or{StaticResource}. - Do NOT use `{Binding}` in `Setter.Value` — Not supported in WinUI 3. Use
{StaticResource}. - Do NOT use `{x:Static}` — Replace with
{x:Bind},x:Uid, or code-behind. - Do NOT use `{x:Type}` — Not supported. Use
x:DataTypefor DataTemplate, or code-behind. - Do NOT use `clr-namespace:` — Replace with
using:in all xmlns declarations. - Do NOT use `Style.Triggers` / `DataTrigger` / `EventTrigger` — Replace with
VisualStateManager. - Do NOT use `MultiBinding` — Replace with
x:Bindfunction binding or computed ViewModel property. - Do NOT mechanically port WPF `IValueConverter` classes — Prefer control
VisualStates, direct{x:Bind}Boolean-to-Visibilityconversion, resources supplied byXamlControlsResources, orCommunityToolkit.WinUI.Converters. Reuse converter instances and invert them withConverterParameter=Truewhen supported; write a custom converter only for app-specific conversion logic. See Value Converter Decision Guide. - Do NOT use `Visibility="Hidden"` — WinUI only has
VisibleandCollapsed. UseOpacity="0"if layout must be preserved. - Do NOT use `IsDefault` / `IsCancel` — Use
AccentButtonStylefor primary button; handle Enter/Escape in code-behind. - Do NOT omit `BasedOn` when overriding default styles — Without it, your style replaces the entire default. Always use
BasedOn="{StaticResource DefaultButtonStyle}"etc. - Do NOT omit `XamlControlsResources` as first merged dictionary — It provides default Fluent styles. Without it, controls have no visual appearance.
Code-behind prohibitions:
- Do NOT use `Application.Current.Dispatcher` — Store
DispatcherQueuein a static field explicitly. - Do NOT use `Window.Current` — Not supported. Use a custom
App.Windowstatic property. - Do NOT put `DataContext`, `Resources`, or `VisualStateManager` on `Window` — WinUI 3
Windowis NOT aDependencyObject. Use a rootPage/UserControl/Grid. - Do NOT use tunneling/preview events (
PreviewMouseDown,PreviewKeyDown) — WinUI has no tunneling. Use bubbling equivalents withHandledproperty orAddHandler(handledEventsToo: true).
Resource prohibitions:
- Do NOT use `Properties.Resources.MyString` — Replace with
ResourceLoaderInstance.ResourceLoader.GetString("MyString"). - Do NOT initialize `ResourceLoader`-dependent values as static fields — Wrap in
Lazy<T>or null-coalescing property. - Do NOT use `pack://` URIs — Replace with
ms-appx:///scheme.
Quick Reference Tables
Namespace Mapping
| WPF | WinUI 3 | Notes | |
|---|---|---|---|
System.Windows | Microsoft.UI.Xaml | Root namespace | |
System.Windows.Controls | Microsoft.UI.Xaml.Controls | Core controls | |
System.Windows.Controls.Primitives | Microsoft.UI.Xaml.Controls.Primitives | Low-level primitives | |
System.Windows.Media | Microsoft.UI.Xaml.Media | Brushes, transforms | |
System.Windows.Media.Animation | Microsoft.UI.Xaml.Media.Animation | Storyboard, animations | |
System.Windows.Media.Imaging | Microsoft.UI.Xaml.Media.Imaging (UI) / Windows.Graphics.Imaging (processing) | Split by purpose | |
System.Windows.Media.Media3D | No equivalent | Use Win2D or Composition APIs | |
System.Windows.Shapes | Microsoft.UI.Xaml.Shapes | Rectangle, Ellipse, Path | |
System.Windows.Input | Microsoft.UI.Xaml.Input | Pointer, keyboard, focus | |
System.Windows.Data | Microsoft.UI.Xaml.Data | Binding, IValueConverter | |
System.Windows.Documents | Microsoft.UI.Xaml.Documents | Limited — RichTextBlock + Paragraph | |
System.Windows.Markup | Microsoft.UI.Xaml.Markup | XAML parsing, markup extensions | |
System.Windows.Automation | Microsoft.UI.Xaml.Automation | Accessibility / UI Automation | |
System.Windows.Navigation | No direct equivalent | Use Frame.Navigate() | |
System.Windows.Threading | Microsoft.UI.Dispatching | Dispatcher → DispatcherQueue | |
System.Windows.Interop | WinRT.Interop / Microsoft.UI.Xaml.Hosting | HWND interop |
Control Replacements (No 1:1 Mapping)
These WPF controls have no direct counterpart and require a different control or third-party package:
| WPF Control | WinUI 3 Replacement | Notes | |
|---|---|---|---|
DataGrid | `WinUI.TableView` | Community library; the Toolkit DataGrid is no longer maintained. Legacy code may still pin v7 CommunityToolkit.WinUI.UI.Controls.DataGrid 7.1.2 | |
Ribbon | CommandBar / NavigationView, or Toolkit Labs Ribbon | No first-party Ribbon in WinUI; Labs component is experimental/partial | |
Menu / MenuItem | MenuBar / MenuBarItem / MenuFlyout | MenuBar for classic menu, MenuFlyout for context | |
ContextMenu | MenuFlyout | Assign to ContextFlyout property | |
ToolBar / ToolBarTray | CommandBar + AppBarButton | ||
StatusBar | Custom Grid/StackPanel or InfoBar | No StatusBar control | |
TabControl | TabView or NavigationView (top mode) | TabView for closeable tabs | |
DocumentViewer | WebView2 | Render PDFs/XPS inside WebView2 | |
FlowDocument | RichTextBlock | Partial replacement only | |
RichTextBox | RichEditBox | Rich text editing | |
GroupBox | Expander (built-in) or HeaderedContentControl (Toolkit) | See Layout & Header Controls from CommunityToolkit.WinUI below | |
Label | TextBlock | WPF Label is a ContentControl; use TextBlock + AccessKey | |
TreeView | TreeView (native) | Available natively, but data binding model differs significantly | |
MessageBox | ContentDialog | Must set XamlRoot before ShowAsync() | |
MediaElement | MediaPlayerElement | Different API | |
AccessText | Not available | Use AccessKey property on target control |
Layout & Header Controls from CommunityToolkit.WinUI
These WPF controls have no built-in WinUI 3 equivalent — install the corresponding CommunityToolkit package. The NuGet package id and the XAML namespace differ intentionally: package names end in .Primitives / .HeaderedControls, but the registered XAML namespace is the shorter CommunityToolkit.WinUI.Controls (confirmed in the official Microsoft Q&A).
| WPF Control | WinUI 3 Replacement | NuGet Package | XAML Namespace | |
|---|---|---|---|---|
WrapPanel | WrapPanel | CommunityToolkit.WinUI.Controls.Primitives | using:CommunityToolkit.WinUI.Controls | |
UniformGrid | UniformGrid | CommunityToolkit.WinUI.Controls.Primitives | using:CommunityToolkit.WinUI.Controls | |
DockPanel | DockPanel | CommunityToolkit.WinUI.Controls.Primitives | using:CommunityToolkit.WinUI.Controls | |
GroupBox (alt.) | HeaderedContentControl | CommunityToolkit.WinUI.Controls.HeaderedControls | using:CommunityToolkit.WinUI.Controls |
No Equivalent — Requires Architectural Rework
These WPF features have no WinUI counterpart and require redesign, not find-and-replace:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 3 Jul 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/wpf-to-winui3-migration/SKILL.md
Popularity
- Repository stars
- 135,973
- Repository forks
- 8,187
- 7-day trend score
- 59
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/powertoys/wpf-to-winui3-migration)