{"record":{"id":"f4f038fe3ded18bb","repo":"dotnet/maui","slug":"removepage-is-not-supported-globally-on-windows-p-f4f038","errorCode":null,"errorMessage":"RemovePage is not supported globally on Windows, please use a NavigationPage.","messagePattern":"RemovePage 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":213,"sourceCode":"\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()\n\t\t{\n\t\t\treturn ((INavigation)this).PopModalAsync(true);\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page page, bool animated)","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Platform.cs#L195-L231","documentation":"Thrown by the WPF Platform's INavigation.RemovePage implementation. Removing a page from the navigation stack is unsupported at the global platform level on Windows/WPF. Only NavigationPage maintains the stack from which pages can be removed.","triggerScenarios":"Calling Application.Current.MainPage.Navigation.RemovePage(page) when the MainPage is not a NavigationPage.","commonSituations":"Shared code removes a page from the stack after navigation (e.g., removing a login page), but the WPF host was not set up with a NavigationPage.","solutions":["Ensure MainPage is wrapped in a NavigationPage before calling RemovePage.","Cast to NavigationPage and call RemovePage on it directly.","If the intent is to replace the visible page, set MainPage directly instead of using RemovePage."],"exampleFix":"// before\nApplication.Current.MainPage.Navigation.RemovePage(loginPage);\n\n// after\nvar navPage = Application.Current.MainPage as NavigationPage;\nif (navPage != null)\n    navPage.Navigation.RemovePage(loginPage);","handlingStrategy":"validation","validationCode":"if (Application.Current.MainPage is NavigationPage navPage)\n    navPage.Navigation.RemovePage(page);","typeGuard":"static bool CanRemovePage(Page root) => root is NavigationPage;","tryCatchPattern":null,"preventionTips":["Only call RemovePage when the host is a NavigationPage.","Guard shared code with a NavigationPage type check."],"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"}