{"record":{"id":"6ae836d1112cad87","repo":"dotnet/maui","slug":"removepage-is-not-supported-globally-on-gtk-pleas","errorCode":null,"errorMessage":"RemovePage is not supported globally on GTK, please use a NavigationPage.","messagePattern":"RemovePage is not supported globally on GTK, please use a NavigationPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/GTK/Platform.cs","lineNumber":279,"sourceCode":"\t\t\t\t\t\tif (page.Children != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tforeach (var child in page.Children)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tchild.ShowAll();\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tpage.ShowAll();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn Task.FromResult<object>(null);\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 GTK, please use a NavigationPage.\");\n\t\t}\n\n\t\tinternal class DefaultRenderer : VisualElementRenderer<VisualElement, Widget>\n\t\t{\n\n\t\t}\n\t}\n}\n","sourceCodeStart":261,"sourceCodeEnd":288,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/GTK/Platform.cs#L261-L288","documentation":"RemovePage (which takes a Page out of the middle of a navigation stack) is a stack-level operation. The global GTK Platform has no page stack — only a modal list — so it cannot remove a page and throws. Removal must be performed by a NavigationPage that owns the stack it is editing.","triggerScenarios":"Calling Navigation.RemovePage(page) when Navigation points at the global GTK Platform: MainPage is not a NavigationPage, so RemovePage has no stack to act on.","commonSituations":"Login-flow code that removes the login page after success via Navigation.RemovePage. Shared navigation utilities that assume a global stack exists on every backend.","solutions":["Ensure the page lives inside a NavigationPage (Application.Current.MainPage = new NavigationPage(root)), then call Navigation.RemovePage on a page within that NavigationPage.","Re-implement the flow using modal push/pop if a NavigationPage is not appropriate for GTK.","Guard with a runtime check so RemovePage is only called when a NavigationPage ancestor exists."],"exampleFix":"// before\nMainPage = new ContentPage();\nNavigation.RemovePage(loginPage); // throws on GTK\n\n// after\nMainPage = new NavigationPage(loginPage);\n// after login success:\nawait Navigation.PushAsync(homePage);\nNavigation.RemovePage(loginPage);","handlingStrategy":"validation","validationCode":"if (page.Parent is NavigationPage np && np.Navigation.NavigationStack.Contains(target))\n    Navigation.RemovePage(target);","typeGuard":"static bool CanRemovePage(Page target) =>\n    target?.Parent is NavigationPage;","tryCatchPattern":null,"preventionTips":["Only call RemovePage against a NavigationPage-owned stack.","Verify the page is present in NavigationStack before removing.","Keep login/wizard flows inside a NavigationPage."],"tags":["gtk","navigation","navigationpage","platform-limitation","maui","xamarin"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}