dotnet/maui · error · InvalidOperationException

PopAsync is not supported globally on Windows, please use a

Error message

PopAsync is not supported globally on Windows, please use a NavigationPage.

What it means

Thrown by the WPF Platform's INavigation.PopAsync(bool) implementation. Popping a page from the navigation stack is unsupported at the global platform level on Windows/WPF because there is no stack-host. Only NavigationPage implements a pop operation.

Source

Thrown at src/Compatibility/Core/src/WPF/Platform.cs:203

		Task<Page> INavigation.PopAsync()
		{
			return ((INavigation)this).PopAsync(true);
		}

		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)

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Wrap the root in a NavigationPage so PopAsync operates against the NavigationPage's internal stack.
  2. Call PopAsync from a NavigationPage reference obtained via ((NavigationPage)MainPage).
  3. Use PopModalAsync if the page was pushed modally (modal stack IS supported globally).

Example fix

// before
await Application.Current.MainPage.Navigation.PopAsync();

// after
Application.Current.MainPage = new NavigationPage(new MainPage());
await Application.Current.MainPage.Navigation.PopAsync();
Defensive patterns

Strategy: validation

Validate before calling

if (Application.Current.MainPage is NavigationPage navPage && navPage.Navigation.NavigationStack.Count > 1)
    await navPage.PopAsync();

Type guard

static bool CanPop(Page root) => root is NavigationPage;

Prevention

When it happens

Trigger: Calling Application.Current.MainPage.Navigation.PopAsync() when MainPage is not a NavigationPage.

Common situations: Shared code calls Navigation.PopAsync after the WPF app set a plain ContentPage as MainPage, or after a modal-only navigation flow.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/26b9b9dee7d260ab. Report an issue: GitHub.