{"record":{"id":"77178db6e4eacef6","repo":"dotnet/maui","slug":"poptorootasync-is-not-supported-globally-on-window-77178d","errorCode":null,"errorMessage":"PopToRootAsync is not supported globally on Windows, please use a NavigationPage.","messagePattern":"PopToRootAsync 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":222,"sourceCode":"\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}\n\n\t\tTask INavigation.PushModalAsync(Page page)\n\t\t{\n\t\t\treturn ((INavigation)this).PushModalAsync(page, true);\n\t\t}","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/Windows/Platform.cs#L204-L240","documentation":"The Windows Platform class's explicit INavigation.PopToRootAsync(bool) throws unconditionally. Clearing the navigation stack back to root is only supported through a NavigationPage host, not the global Platform navigation context on Windows.","triggerScenarios":"Calling Application.Current.MainPage.Navigation.PopToRootAsync() when MainPage is not a NavigationPage. The global Platform INavigation rejects the operation.","commonSituations":"Shared code calling PopToRootAsync after deep linking or logout flow; cross-platform navigation abstraction that doesn't account for Windows limitations.","solutions":["Use NavigationPage as the root container so PopToRootAsync operates on its internal stack","Manually reset MainPage to the root page instead of using PopToRootAsync","Branch navigation calls per-platform using OnPlatform or Device.RuntimePlatform"],"exampleFix":"// before\nMainPage = new MyContentPage();\nawait MainPage.Navigation.PopToRootAsync(); // throws\n\n// after\nMainPage = new NavigationPage(new MyContentPage());\nawait MainPage.Navigation.PopToRootAsync(); // works","handlingStrategy":"validation","validationCode":"// Before calling PopToRootAsync, verify NavigationPage\nif (Application.Current.MainPage is NavigationPage navPage && navPage.Navigation.NavigationStack.Count > 1)\n{\n    await navPage.Navigation.PopToRootAsync();\n}","typeGuard":"static bool HasNavigationStack()\n{\n    return Application.Current.MainPage is NavigationPage nav\n        && nav.Navigation.NavigationStack.Count > 1;\n}","tryCatchPattern":null,"preventionTips":["Ensure NavigationPage wraps the root page before using PopToRootAsync","Check stack depth before popping to root","Test deep navigation flows on Windows specifically"],"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"}