{"record":{"id":"350c114326e52132","repo":"dotnet/maui","slug":"pushasync-is-not-supported-globally-on-windows-pl","errorCode":null,"errorMessage":"PushAsync is not supported globally on Windows, please use a NavigationPage.","messagePattern":"PushAsync 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":198,"sourceCode":"\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);\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopToRootAsync(true);\n\t\t}\n\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)","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Platform.cs#L180-L216","documentation":"Thrown by the WPF Platform's explicit INavigation.PushAsync(Page, bool) implementation. The global Windows/WPF platform cannot push pages onto a stack because it has no built-in navigation host. Page-stack navigation requires a NavigationPage wrapper.","triggerScenarios":"Calling Application.Current.MainPage.Navigation.PushAsync(page) or the equivalent global INavigation.PushAsync when MainPage is not a NavigationPage.","commonSituations":"Shared PCL/netstandard code calls Navigation.PushAsync at startup, but the WPF host was initialized with a bare ContentPage. Common when porting from iOS/Android where MainPage was already a NavigationPage.","solutions":["Set Application.Current.MainPage to a new NavigationPage(rootPage) before calling PushAsync.","Use NavigationPage.PushAsync from a NavigationPage instance rather than the global proxy.","Conditional-check in shared code: if (mainPage is NavigationPage navPage) navPage.PushAsync(page)."],"exampleFix":"// before\nApplication.Current.MainPage = new MainPage();\nawait Application.Current.MainPage.Navigation.PushAsync(new DetailPage());\n\n// after\nApplication.Current.MainPage = new NavigationPage(new MainPage());\nawait Application.Current.MainPage.Navigation.PushAsync(new DetailPage());","handlingStrategy":"validation","validationCode":"if (Application.Current.MainPage is NavigationPage navPage)\n    await navPage.PushAsync(page);","typeGuard":"static bool CanPush(Page root) => root is NavigationPage;","tryCatchPattern":null,"preventionTips":["Bootstrap the WPF/Windows app with new NavigationPage(rootPage) as MainPage.","In shared code, check for NavigationPage before calling PushAsync on the global proxy."],"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"}