{"record":{"id":"018df2c85bff0e0f","repo":"dotnet/maui","slug":"popasync-is-not-supported-globally-on-windows-ple-018df2","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/Windows/Platform.cs","lineNumber":217,"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(\n\t\t\t\t\"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(\n\t\t\t\t\"InsertPageBefore is not supported globally on Windows, please use a NavigationPage.\");\n\t\t}","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/Windows/Platform.cs#L199-L235","documentation":"The Windows Platform class's explicit INavigation.PopAsync(bool) throws unconditionally. PopAsync (removing the current page from the stack) is only supported when a NavigationPage manages the stack, not through the global Platform navigation context.","triggerScenarios":"Calling Application.Current.MainPage.Navigation.PopAsync() when MainPage is not wrapped in a NavigationPage. The global Platform INavigation implementation rejects all stack-based pop operations.","commonSituations":"Shared navigation code that calls PopAsync without checking the page hierarchy; app structured with a single root page rather than NavigationPage on Windows.","solutions":["Wrap the root page in a NavigationPage so PopAsync delegates to NavigationPage's navigation stack","Use modal navigation (PopModalAsync) which is supported globally","Conditionally branch navigation logic for Windows platform"],"exampleFix":"// before\nMainPage = new MyContentPage();\nawait MainPage.Navigation.PopAsync(); // throws\n\n// after\nMainPage = new NavigationPage(new MyContentPage());\nawait MainPage.Navigation.PopAsync(); // works","handlingStrategy":"validation","validationCode":"// Before calling PopAsync, verify NavigationPage hosts the stack\nif (Application.Current.MainPage is NavigationPage navPage && navPage.Navigation.NavigationStack.Count > 1)\n{\n    await navPage.Navigation.PopAsync();\n}\nelse\n{\n    // Cannot pop — either no NavigationPage or already at root\n    Application.Current.MainPage = rootPage; // reset directly\n}","typeGuard":"static bool CanPop()\n{\n    return Application.Current.MainPage is NavigationPage nav\n        && nav.Navigation.NavigationStack.Count > 1;\n}","tryCatchPattern":null,"preventionTips":["Use NavigationPage as the root container on all platforms","Check Navigation.NavigationStack.Count before calling PopAsync","Abstract navigation behind a service to centralize platform checks"],"tags":["navigation","winui","uwp","maui-compatibility","platform-limitation"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}