{"record":{"id":"26b9b9dee7d260ab","repo":"dotnet/maui","slug":"popasync-is-not-supported-globally-on-windows-ple","errorCode":null,"errorMessage":"PopAsync is not supported globally on Windows, please use a NavigationPage.","messagePattern":"PopAsync is not supported globally on Windows, please use a NavigationPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/WPF/Platform.cs","lineNumber":203,"sourceCode":"\n\t\tTask<Page> INavigation.PopAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopAsync(true);\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopToRootAsync(true);\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root, bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PushAsync is not supported globally on Windows, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask<Page> INavigation.PopAsync(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PopAsync is not supported globally on Windows, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PopToRootAsync is not supported globally on Windows, please use a NavigationPage.\");\n\t\t}\n\n\t\tvoid INavigation.RemovePage(Page page)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"RemovePage is not supported globally on Windows, please use a NavigationPage.\");\n\t\t}\n\n\t\tvoid INavigation.InsertPageBefore(Page page, Page before)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"InsertPageBefore is not supported globally on Windows, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page page)","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Platform.cs#L185-L221","documentation":"Thrown by the WPF Platform's INavigation.PopAsync(bool) implementation. Popping a page from the navigation stack is unsupported at the global platform level on Windows/WPF because there is no stack-host. Only NavigationPage implements a pop operation.","triggerScenarios":"Calling Application.Current.MainPage.Navigation.PopAsync() when MainPage is not a NavigationPage.","commonSituations":"Shared code calls Navigation.PopAsync after the WPF app set a plain ContentPage as MainPage, or after a modal-only navigation flow.","solutions":["Wrap the root in a NavigationPage so PopAsync operates against the NavigationPage's internal stack.","Call PopAsync from a NavigationPage reference obtained via ((NavigationPage)MainPage).","Use PopModalAsync if the page was pushed modally (modal stack IS supported globally)."],"exampleFix":"// before\nawait Application.Current.MainPage.Navigation.PopAsync();\n\n// after\nApplication.Current.MainPage = new NavigationPage(new MainPage());\nawait Application.Current.MainPage.Navigation.PopAsync();","handlingStrategy":"validation","validationCode":"if (Application.Current.MainPage is NavigationPage navPage && navPage.Navigation.NavigationStack.Count > 1)\n    await navPage.PopAsync();","typeGuard":"static bool CanPop(Page root) => root is NavigationPage;","tryCatchPattern":null,"preventionTips":["Ensure MainPage is a NavigationPage before any PopAsync calls in shared code.","Use PopModalAsync if the page was pushed modally."],"tags":["wpf","maui-compatibility","navigation","navigationpage","platform"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}