{"record":{"id":"9b0a9c5ac87d64c2","repo":"dotnet/maui","slug":"removepage-is-not-supported-globally-on-windows-p","errorCode":null,"errorMessage":"RemovePage is not supported globally on Windows, please use a LightNavigationPage.","messagePattern":"RemovePage is not supported globally on Windows, please use a LightNavigationPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/WPF/Interfaces/IFormsNavigation.cs","lineNumber":106,"sourceCode":"\n\t\tpublic void Push(object page, bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Push is not supported globally on Windows, please use a LightNavigationPage.\");\n\t\t}\n\n\t\tpublic void PushModal(object page)\n\t\t{\n\t\t\tPushModal(page, true);\n\t\t}\n\n\t\tpublic void PushModal(object page, bool animated)\n\t\t{\n\t\t\tParentWindow?.PushModal(page, animated);\n\t\t}\n\n\t\tpublic void RemovePage(object page)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\n\t\t\t\t\"RemovePage is not supported globally on Windows, please use a LightNavigationPage.\");\n\t\t}\n\n\t\tpublic int StackDepth =>\n\t\t\tthrow new InvalidOperationException(\n\t\t\t\t\"StackDepth is not supported globally on Windows, please use a LightNavigationPage.\");\n\t}\n}","sourceCodeStart":88,"sourceCodeEnd":114,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Interfaces/IFormsNavigation.cs#L88-L114","documentation":"IFormsNavigation.RemovePage throws InvalidOperationException stating RemovePage is not supported globally on Windows and instructs to use a LightNavigationPage. The FormsWindow navigation proxy rejects page removal; only a LightNavigationPage supports stack mutation.","triggerScenarios":"Calling Navigation.RemovePage(page) against the window-level navigation proxy; removing pages from the global stack instead of a per-page NavigationPage.","commonSituations":"Cross-platform code removing pages from the back stack; pages not wrapped in a LightNavigationPage.","solutions":["Use a LightNavigationPage and call RemovePage on that instance.","Branch by platform: only remove pages when Navigation is a per-page NavigationPage.","Ensure NavigationProxy resolves to the page-level NavigationPage.","Provide a WPF-specific INavigation implementation if removal is required."],"exampleFix":"// before\nNavigation.RemovePage(oldPage);\n\n// after\nif (Navigation is LightNavigationPage lnp)\n    lnp.RemovePage(oldPage);","handlingStrategy":"type-guard","validationCode":"if (Navigation is LightNavigationPage lnp) lnp.RemovePage(page);\nelse throw new PlatformNotSupportedException(\"Use LightNavigationPage on WPF.\");","typeGuard":"static bool CanRemove(NavigationProxy n) => n is LightNavigationPage;","tryCatchPattern":"try { Navigation.RemovePage(page); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"LightNavigationPage\"))\n{ /* wrap in LightNavigationPage, retry */ }","preventionTips":["Use LightNavigationPage when stack mutation is needed on WPF.","Branch remove logic by Navigation type.","Audit NavigationProxy routing."],"tags":["wpf","navigation","not-supported","light-navigation-page"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}