dotnet/maui · error · InvalidOperationException
PopToRootAsync is not supported globally on Windows, please
Error message
PopToRootAsync is not supported globally on Windows, please use a NavigationPage.
What it means
Thrown by the WPF Platform's INavigation.PopToRootAsync(bool) implementation. The global Windows/WPF platform has no notion of a navigation stack to pop to root. PopToRoot is only meaningful on a NavigationPage.
Source
Thrown at src/Compatibility/Core/src/WPF/Platform.cs:208
Task INavigation.PopToRootAsync()
{
return ((INavigation)this).PopToRootAsync(true);
}
Task INavigation.PushAsync(Page root, bool animated)
{
throw new InvalidOperationException("PushAsync is not supported globally on Windows, please use a NavigationPage.");
}
Task<Page> INavigation.PopAsync(bool animated)
{
throw new InvalidOperationException("PopAsync is not supported globally on Windows, please use a NavigationPage.");
}
Task INavigation.PopToRootAsync(bool animated)
{
throw new InvalidOperationException("PopToRootAsync is not supported globally on Windows, please use a NavigationPage.");
}
void INavigation.RemovePage(Page page)
{
throw new InvalidOperationException("RemovePage is not supported globally on Windows, please use a NavigationPage.");
}
void INavigation.InsertPageBefore(Page page, Page before)
{
throw new InvalidOperationException("InsertPageBefore is not supported globally on Windows, please use a NavigationPage.");
}
Task INavigation.PushModalAsync(Page page)
{
return ((INavigation)this).PushModalAsync(page, true);
}
Task<Page> INavigation.PopModalAsync()View on GitHub (pinned to f377ff1c5e)
Solutions
- Set MainPage to a NavigationPage so PopToRootAsync can clear the internal page stack.
- Obtain the NavigationPage reference explicitly and call PopToRootAsync on it.
- If only modal pages were used, manually dismiss modal pages via PopModalAsync instead.
Example fix
// before await Application.Current.MainPage.Navigation.PopToRootAsync(); // after Application.Current.MainPage = new NavigationPage(new RootPage()); await Application.Current.MainPage.Navigation.PopToRootAsync();
Defensive patterns
Strategy: validation
Validate before calling
if (Application.Current.MainPage is NavigationPage navPage)
await navPage.PopToRootAsync(); Type guard
static bool CanPopToRoot(Page root) => root is NavigationPage;
Prevention
- Set up a NavigationPage host before calling PopToRootAsync.
- Check the page type in shared code before invoking stack-reset operations.
When it happens
Trigger: Calling Application.Current.MainPage.Navigation.PopToRootAsync() when MainPage is not a NavigationPage.
Common situations: Shared code resets navigation via PopToRootAsync, but the WPF entry point used a TabbedPage or ContentPage root without a NavigationPage host.
Related errors
- NavigationStack is not supported globally on Windows, please
- PushAsync is not supported globally on Windows, please use a
- PopAsync is not supported globally on Windows, please use a
- RemovePage is not supported globally on Windows, please use
- InsertPageBefore is not supported globally on Windows, pleas
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/e63cc8e36de80f51.
Report an issue: GitHub.