{"record":{"id":"4b05f5ba7bde5e0d","repo":"dotnet/maui","slug":"navigationstack-is-not-supported-globally-on-windo","errorCode":null,"errorMessage":"NavigationStack is not supported globally on Windows, please use a NavigationPage.","messagePattern":"NavigationStack 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":170,"sourceCode":"\t\t\tself.SetValue(RendererProperty, renderer);\n\t\t\tself.IsPlatformEnabled = renderer != null;\n\t\t}\n\n\t\tinternal void SetPage(Page newRoot)\n\t\t{\n\t\t\tif (newRoot == null)\n\t\t\t\treturn;\n\n\t\t\tPage = newRoot;\n\n\t\t\t_page.StartupPage = Page;\n\t\t\tApplication.Current.NavigationProxy.Inner = this;\n\t\t}\n\n\n\t\tpublic IReadOnlyList<Page> NavigationStack\n\t\t{\n\t\t\tget { throw new InvalidOperationException(\"NavigationStack is not supported globally on Windows, please use a NavigationPage.\"); }\n\t\t}\n\n\t\tpublic IReadOnlyList<Page> ModalStack\n\t\t{\n\t\t\tget\n\t\t\t{\n\t\t\t\treturn _page.InternalChildren.Cast<Page>().ToList();\n\t\t\t}\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root)\n\t\t{\n\t\t\treturn ((INavigation)this).PushAsync(root, true);\n\t\t}\n\n\t\tTask<Page> INavigation.PopAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopAsync(true);","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Platform.cs#L152-L188","documentation":"Thrown by the WPF Platform's INavigation.NavigationStack getter. The global Windows/WPF platform does not maintain a navigation stack — only NavigationPage does. Accessing Application.Current.MainPage.Navigation.NavigationStack without wrapping the root in a NavigationPage triggers this.","triggerScenarios":"Reading NavigationStack from Application.Current.MainPage.Navigation (or the global INavigation proxy) when the MainPage is not a NavigationPage.","commonSituations":"Calling Application.Current.MainPage.Navigation.NavigationStack in shared code that assumes a stack-based nav host, but the Windows/WPF app was bootstrapped with a plain ContentPage or TabbedPage root.","solutions":["Wrap the root page in a NavigationPage: new NavigationPage(new MainPage()).","Access NavigationStack from a NavigationPage instance rather than from the global proxy.","In shared code, check if the current page is a NavigationPage before accessing NavigationStack."],"exampleFix":"// before\nvar stack = Application.Current.MainPage.Navigation.NavigationStack;\n\n// after\nApplication.Current.MainPage = new NavigationPage(new MainPage());\nvar stack = Application.Current.MainPage.Navigation.NavigationStack;","handlingStrategy":"validation","validationCode":"if (Application.Current.MainPage is NavigationPage navPage)\n    var stack = navPage.Navigation.NavigationStack;","typeGuard":"static bool HasNavigationStack(Page page) => page is NavigationPage;","tryCatchPattern":null,"preventionTips":["Always wrap the root page in a NavigationPage at startup if shared code uses stack navigation.","Guard shared navigation code with an is-NavigationPage check before accessing NavigationStack."],"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"}