{"record":{"id":"e63cc8e36de80f51","repo":"dotnet/maui","slug":"poptorootasync-is-not-supported-globally-on-window","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/WPF/Platform.cs","lineNumber":208,"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(\"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)\n\t\t{\n\t\t\treturn ((INavigation)this).PushModalAsync(page, true);\n\t\t}\n\n\t\tTask<Page> INavigation.PopModalAsync()","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Platform.cs#L190-L226","documentation":"Thrown by the WPF Platform's INavigation.PopToRootAsync(bool) implementation. The global Windows/WPF platform has no notion of a navigation stack to pop to root. PopToRoot is only meaningful on a NavigationPage.","triggerScenarios":"Calling Application.Current.MainPage.Navigation.PopToRootAsync() when MainPage is not a NavigationPage.","commonSituations":"Shared code resets navigation via PopToRootAsync, but the WPF entry point used a TabbedPage or ContentPage root without a NavigationPage host.","solutions":["Set MainPage to a NavigationPage so PopToRootAsync can clear the internal page stack.","Obtain the NavigationPage reference explicitly and call PopToRootAsync on it.","If only modal pages were used, manually dismiss modal pages via PopModalAsync instead."],"exampleFix":"// before\nawait Application.Current.MainPage.Navigation.PopToRootAsync();\n\n// after\nApplication.Current.MainPage = new NavigationPage(new RootPage());\nawait Application.Current.MainPage.Navigation.PopToRootAsync();","handlingStrategy":"validation","validationCode":"if (Application.Current.MainPage is NavigationPage navPage)\n    await navPage.PopToRootAsync();","typeGuard":"static bool CanPopToRoot(Page root) => root is NavigationPage;","tryCatchPattern":null,"preventionTips":["Set up a NavigationPage host before calling PopToRootAsync.","Check the page type in shared code before invoking stack-reset operations."],"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"}