{"record":{"id":"8ffa99511cbd959a","repo":"dotnet/maui","slug":"poptoroot-is-not-supported-globally-on-windows-pl","errorCode":null,"errorMessage":"PopToRoot is not supported globally on Windows, please use a LightNavigationPage.","messagePattern":"PopToRoot 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":80,"sourceCode":"\n\t\tpublic void PopModal()\n\t\t{\n\t\t\tPopModal(true);\n\t\t}\n\n\t\tpublic void PopModal(bool animated)\n\t\t{\n\t\t\tParentWindow?.PopModal(animated);\n\t\t}\n\n\t\tpublic void PopToRoot()\n\t\t{\n\t\t\tPopToRoot(true);\n\t\t}\n\n\t\tpublic void PopToRoot(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\n\t\t\t\t\"PopToRoot is not supported globally on Windows, please use a LightNavigationPage.\");\n\t\t}\n\n\t\tpublic void Push(object page)\n\t\t{\n\t\t\tPush(page, true);\n\t\t}\n\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","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Interfaces/IFormsNavigation.cs#L62-L98","documentation":"IFormsNavigation.PopToRoot throws InvalidOperationException stating PopToRoot is not supported globally on Windows and instructs to use a LightNavigationPage. The window-level navigation proxy rejects full-stack pops; only a LightNavigationPage implements them.","triggerScenarios":"Calling Navigation.PopToRootAsync() against the FormsWindow-level navigation proxy; porting code that uses a global navigation stack.","commonSituations":"Cross-platform navigation code calling PopToRootAsync unconditionally; not wrapping pages in a LightNavigationPage; misrouted NavigationProxy.","solutions":["Use a LightNavigationPage and call PopToRoot on that instance.","Branch by platform: only call PopToRootAsync when Navigation is a per-page NavigationPage.","Verify the Forms NavigationProxy resolves to the page-level NavigationPage.","Provide a WPF-specific INavigation wrapper that throws a clearer message or delegates correctly."],"exampleFix":"// before\nawait Navigation.PopToRootAsync();\n\n// after\nif (Navigation is LightNavigationPage lnp)\n    await lnp.PopToRootAsync();","handlingStrategy":"type-guard","validationCode":"if (Navigation is LightNavigationPage lnp) await lnp.PopToRootAsync();\nelse throw new PlatformNotSupportedException(\"Use LightNavigationPage on WPF.\");","typeGuard":"static bool CanPopToRoot(NavigationProxy n) => n is LightNavigationPage;","tryCatchPattern":"try { await Navigation.PopToRootAsync(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"LightNavigationPage\"))\n{ /* ensure LightNavigationPage, retry */ }","preventionTips":["Wrap pages in LightNavigationPage before any pop-to-root on WPF.","Branch by platform for stack-reset calls.","Verify NavigationProxy is per-page."],"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"}