Stale UWP Patterns
AI agents often generate UWP or WinUI 2 code when asked for WinUI 3. Use this page as a review checklist.
Migration Table
| Scenario | Reject | Use |
|---|---|---|
| XAML namespace | Windows.UI.Xaml.* | Microsoft.UI.Xaml.* |
| Dialog | Windows.UI.Popups.MessageDialog | ContentDialog with XamlRoot |
| Dispatcher | CoreDispatcher.RunAsync | DispatcherQueue.TryEnqueue |
| Current window | Window.Current | Explicit MainWindow or window registry |
| Window management | ApplicationView, CoreWindow | Microsoft.UI.Windowing.AppWindow |
| Title bar | CoreApplicationViewTitleBar | AppWindowTitleBar or current title bar APIs |
| Share | Direct UWP DataTransferManager | Desktop interop with HWND where required |
Direct UWP PrintManager | Desktop interop with HWND where required | |
| Background task | UWP IBackgroundTask | Desktop service/lifecycle/activation model |
| XAML tests | Normal unit test host for XAML | WinUI Unit Test App and [UITestMethod] |
| XAML Islands | Treat as WinUI 3 | Treat as UWP XAML hosting path |
Code Review Search
Run targeted searches in a source repo:
rg "Windows\.UI\.Xaml|CoreDispatcher|Window\.Current|ApplicationView|CoreWindow|MessageDialog|IBackgroundTask"
If any result appears, verify it is either intentionally historical/migration-only or replace it.
Dispatcher Example
DispatcherQueue.TryEnqueue(() =>
{
StatusText.Text = "Done";
});
Dialog Example
var dialog = new ContentDialog
{
Title = "Confirm",
Content = "Continue?",
PrimaryButtonText = "Continue",
CloseButtonText = "Cancel",
XamlRoot = this.Content.XamlRoot,
};
await dialog.ShowAsync();
Warning: Do not accept generated WinUI code until it passes this stale-UWP search.