/dotnet-desktop-development:winui3-migration-guidefrom dotnet-desktop-development
Maps UWP APIs and patterns to WinUI 3 and Windows App SDK equivalents with migration rules for namespaces, threading, windowing, dialogs, pickers, and common Copilot mistakes.
Ships in dotnet-desktop-development. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Migrate UWP code to WinUI 3 / Windows App SDK by replacing legacy APIs with desktop-safe equivalents. Review generated code for UWP-only patterns and produce concrete before/after guidance.
All Windows.UI.Xaml.* namespaces move to Microsoft.UI.Xaml.*.
| UWP namespace | WinUI 3 namespace |
|---|---|
Windows.UI.Xaml | Microsoft.UI.Xaml |
Windows.UI.Xaml.Controls | Microsoft.UI.Xaml.Controls |
Windows.UI.Xaml.Media | Microsoft.UI.Xaml.Media |
Windows.UI.Xaml.Input | Microsoft.UI.Xaml.Input |
Windows.UI.Xaml.Data | Microsoft.UI.Xaml.Data |
Windows.UI.Xaml.Navigation | Microsoft.UI.Xaml.Navigation |
Windows.UI.Xaml.Shapes | Microsoft.UI.Xaml.Shapes |
Windows.UI.Composition | Microsoft.UI.Composition |
Windows.UI.Input | Microsoft.UI.Input |
Windows.UI.Colors | Microsoft.UI.Colors |
Windows.UI.Text | Microsoft.UI.Text |
Windows.UI.Core | Microsoft.UI.Dispatching for dispatcher work |
Use WRONG/CORRECT examples for subtle migrations, especially File/Folder picker ownership and dialog threading issues.
| Mistake | Why it fails | Correct pattern |
|---|---|---|
ContentDialog without XamlRoot | Throws InvalidOperationException in WinUI 3. | Set XamlRoot = this.Content.XamlRoot before ShowAsync(). |
Windows.UI.Popups.MessageDialog | UWP API, not available in WinUI 3 desktop. | Use ContentDialog with PrimaryButtonText, CloseButtonText, and ContentDialogResult.Primary. |
CoreDispatcher.RunAsync | CoreDispatcher does not exist in WinUI 3. | Use DispatcherQueue.TryEnqueue() or DispatcherQueue.TryEnqueue(DispatcherQueuePriority.High, ...). |
Window.Current | No current-window singleton in WinUI 3 desktop. | Store public static Window MainWindow { get; private set; } in App during OnLaunched. |
| Pickers without HWND initialization | Desktop pickers need an owner window. | Use WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow) and WinRT.Interop.InitializeWithWindow.Initialize(picker, hwnd). |
// Correct ContentDialog pattern
var dialog = new ContentDialog
{
Title = "Confirm",
Content = "Are you sure?",
PrimaryButtonText = "Yes",
CloseButtonText = "No",
XamlRoot = this.Content.XamlRoot
};
var result = await dialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
// User confirmed
}
// Correct DispatcherQueue pattern
DispatcherQueue.TryEnqueue(() =>
{
StatusText.Text = "Done";
});
DispatcherQueue.TryEnqueue(DispatcherQueuePriority.High, () =>
{
ProgressBar.Value = 100;
});
// Correct picker pattern
var picker = new FileOpenPicker();
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow);
WinRT.Interop.InitializeWithWindow.Initialize(picker, hwnd);
picker.FileTypeFilter.Add(".txt");
var file = await picker.PickSingleFileAsync();
| UWP API or pattern | WinUI 3 / Windows App SDK replacement |
|---|---|
Window.Current | Track App.MainWindow or pass a Window reference explicitly. |
ApplicationView.TryResizeView() | AppWindow.Resize() |
AppWindow.TryCreateAsync() | AppWindow.Create() |
AppWindow.TryShowAsync() | AppWindow.Show() |
AppWindow.TryConsolidateAsync() | AppWindow.Destroy() |
AppWindow.RequestMoveXxx() | AppWindow.Move() |
AppWindow.GetPlacement() | AppWindow.Position property |
AppWindow.RequestPresentation() | AppWindow.SetPresenter() |
CoreApplicationViewTitleBar | AppWindowTitleBar |
CoreApplicationView.TitleBar.ExtendViewIntoTitleBar | AppWindow.TitleBar.ExtendsContentIntoTitleBar |
public partial class App : Application
{
public static Window MainWindow { get; private set; }
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
MainWindow = new MainWindow();
MainWindow.Activate();
}
}
| UWP pattern | WinUI 3 equivalent |
|---|---|
CoreDispatcher.RunAsync(priority, callback) and Dispatcher.RunAsync(CoreDispatcherPriority.Normal, callback) | DispatcherQueue.TryEnqueue(priority, callback); map CoreDispatcherPriority values such as CoreDispatcherPriority.Normal to DispatcherQueuePriority where needed. |
Dispatcher.HasThreadAccess | DispatcherQueue.HasThreadAccess |
CoreDispatcher.ProcessEvents() | No equivalent; restructure async code. |
CoreWindow.GetForCurrentThread() | Use DispatcherQueue.GetForCurrentThread() when appropriate. |
UIViewSettings.GetForCurrentView() | Use AppWindow properties. |
ApplicationView.GetForCurrentView() | AppWindow.GetFromWindowId(windowId) |
DisplayInformation.GetForCurrentView() | Win32 GetDpiForWindow() or XamlRoot.RasterizationScale. |
CoreApplication.GetCurrentView() | Not available; track windows manually. |
SystemNavigationManager.GetForCurrentView() | Handle back navigation in NavigationView directly. |
Key difference: UWP uses ASTA (Application STA) with built-in reentrancy blocking. WinUI 3 uses standard STA without that protection, so review async code for reentrancy when messages are pumped.
| Scenario | UWP pattern | WinUI 3 replacement |
|---|---|---|
| Confirmation dialog | MessageDialog | ContentDialog with XamlRoot. |
| File or folder picker | FileOpenPicker without owner | Initialize with InitializeWithWindow.Initialize(picker, hwnd). |
| Background task | IBackgroundTask, for example MyTask implementing Run(IBackgroundTaskInstance taskInstance) | Microsoft.Windows.AppLifecycle and AppInstance.GetCurrent().GetActivatedEventArgs(). |
| Notification activation | UWP background activation | Check args.Kind == ExtendedActivationKind.AppNotification. |
| Packaged simple settings | ApplicationData.Current.LocalSettings | Keep ApplicationData.Current.LocalSettings. |
| Unpackaged simple settings | ApplicationData.Current.LocalSettings assumption | Use JSON file in LocalApplicationData. |
| Packaged local files | ApplicationData.Current.LocalFolder | Keep ApplicationData.Current.LocalFolder. |
| Unpackaged local files | UWP app data assumptions | Use Environment.GetFolderPath(SpecialFolder.LocalApplicationData). |
using Microsoft.Windows.AppLifecycle;
var args = AppInstance.GetCurrent().GetActivatedEventArgs();
if (args.Kind == ExtendedActivationKind.AppNotification)
{
// Handle background activation
}
| UWP | WinUI 3 |
|---|---|
| Unit Test App (Universal Windows) | Unit Test App (WinUI in Desktop) |
| Standard MSTest project with UWP types | Use WinUI test app for XAML runtime. |
[TestMethod] for all tests | [TestMethod] for logic, [UITestMethod] for XAML/UI tests. |
| Class Library (Universal Windows) | Class Library (WinUI in Desktop) |
[UITestMethod]
public void TestMyControl()
{
var control = new MyLibrary.MyUserControl();
Assert.AreEqual(expected, control.MyProperty);
}
[UITestMethod] runs the test on the XAML UI thread, which is required for instantiating any Microsoft.UI.Xaml type. Update the project file to target net10.0-windows10.0.22621.0 and set <UseWinUI>true</UseWinUI> when that target framework is appropriate for the app.
Windows.UI.Xaml.* using directives with Microsoft.UI.Xaml.*.Windows.UI.Colors with Microsoft.UI.Colors.CoreDispatcher.RunAsync with DispatcherQueue.TryEnqueue.Window.Current with App.MainWindow or explicit window references.XamlRoot to all ContentDialog instances.InitializeWithWindow.Initialize(picker, hwnd).MessageDialog with ContentDialog.ApplicationView and CoreWindow with AppWindow patterns.CoreApplicationViewTitleBar with AppWindowTitleBar.GetForCurrentView() calls with AppWindow or explicit window equivalents.IBackgroundTask with AppLifecycle activation where applicable.net10.0-windows10.0.22621.0, <UseWinUI>true</UseWinUI>.[UITestMethod] for XAML tests.CoreDispatcher.ProcessEvents(): there is no equivalent; change the async design instead of forcing reentrancy.## WinUI 3 migration review — <file, feature, or project>
**Status:** ready | changes required | blocked
**Scope:** <UWP APIs or files reviewed>
| Area | UWP pattern found | WinUI 3 replacement | Evidence | Action |
| --- | --- | --- | --- | --- |
| Dialogs | `MessageDialog` | `ContentDialog` with `XamlRoot` | `<file:line>` | Replace dialog construction |
### Code changes
```csharp
<before/after or corrected WinUI 3 snippet>
```
### Validation
- Packaged configuration: pass | not run | blocked
- Unpackaged configuration: pass | not run | blocked
- XAML/UI tests using `[UITestMethod]`: pass | not run | blocked
Windows.UI.Xaml.* namespace is migrated to Microsoft.UI.Xaml.*.XamlRoot and avoid MessageDialog.CoreDispatcher, CoreWindow, ApplicationView, and GetForCurrentView() usages are replaced or explicitly justified.AppWindow, explicit Window references, or App.MainWindow rather than Window.Current.Microsoft.Windows.AppLifecycle where UWP IBackgroundTask no longer applies.[UITestMethod] for XAML interaction.What SKILL.md sets; muted values are Claude Code's defaults
9 skills in this plugin
/dotnet-timezoneResolve .NET and C# timezone questions with TimeZoneInfo, DateTimeOffset, TimeZoneConverter, NodaTime, UTC conversion, daylight saving time, scheduling, Windows and IANA timezone IDs, location lookup, and copy-paste-ready code. Use this skill when a .NET user needs the timezone for a city, address, region, or country, or asks about cross-platform timezone handling./msstore-cliUse Microsoft Store Developer CLI (msstore) to configure Partner Center credentials, list Store apps, package and publish Windows submissions, check status, manage package flights, gradual rollouts, and CI/CD publishing for Windows App SDK/WinUI, UWP, .NET MAUI, Flutter, Electron, React Native, and PWA apps. Use when asked to configure Store credentials, publish to Microsoft Store, check submission status, or automate Store releases./mvvm-toolkitCommunityToolkit.Mvvm core guidance for ViewModels, source generators, observable properties, commands, validation, and base-class selection. Use this skill when authoring or reviewing code that uses CommunityToolkit.Mvvm 8.x, ObservableObject, ObservableValidator, ObservableRecipient, ObservableProperty, RelayCommand, AsyncRelayCommand, NotifyPropertyChangedFor, NotifyCanExecuteChangedFor, or NotifyDataErrorInfo across WPF, WinUI 3, MAUI, Uno, and Avalonia./mvvm-toolkit-diWire CommunityToolkit.Mvvm ViewModels into Microsoft.Extensions.DependencyInjection for XAML apps. Use this skill when standing up a .NET Generic Host composition root for WPF, WinUI 3, .NET MAUI, Uno, or Avalonia; choosing Singleton, Transient, or Scoped lifetimes; registering IMessenger; resolving ViewModels in Views; using keyed services; adding test seams; or replacing legacy Ioc.Default service-locator code./mvvm-toolkit-messengerConfigure CommunityToolkit.Mvvm Messenger pub/sub for decoupled ViewModel communication. Use this skill when users ask to send messages between ViewModels, choose WeakReferenceMessenger vs StrongReferenceMessenger, use IRecipient<TMessage>, RequestMessage<T>, AsyncRequestMessage<T>, CollectionRequestMessage<T>, ValueChangedMessage<T>, channel tokens, or ObservableRecipient activation in WPF, WinUI 3, .NET MAUI, Uno, or Avalonia./nuget-managerManage NuGet packages safely in .NET projects and solutions using the `dotnet` CLI. Use this skill when adding, removing, or updating package versions, verifying `PACKAGE_NAME` availability, working with `Directory.Packages.props`, or deciding when direct `.csproj` edits are allowed.npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin dotnet-desktop-developmentOther plugins' skills for the same job