dotnet/maui · error · InvalidOperationException

Pop is not supported globally on Windows, please use a Light

Error message

Pop is not supported globally on Windows, please use a LightNavigationPage.

What it means

IFormsNavigation.Pop (and Pop(bool)) throw InvalidOperationException stating Pop is not supported globally on Windows and instructs to use a LightNavigationPage. The global/window-level navigation proxy intentionally rejects stack pops; only a LightNavigationPage supports them.

Source

Thrown at src/Compatibility/Core/src/WPF/Interfaces/IFormsNavigation.cs:60

					return System.Windows.Application.Current.MainWindow as FormsWindow;
				return null;
			}
		}

		public void InsertPageBefore(object page, object before)
		{
			throw new InvalidOperationException(
				"InsertPageBefore is not supported globally on Windows, please use a LightNavigationPage.");
		}

		public void Pop()
		{
			Pop(true);
		}

		public void Pop(bool animated)
		{
			throw new InvalidOperationException("Pop is not supported globally on Windows, please use a LightNavigationPage.");
		}

		public void PopModal()
		{
			PopModal(true);
		}

		public void PopModal(bool animated)
		{
			ParentWindow?.PopModal(animated);
		}

		public void PopToRoot()
		{
			PopToRoot(true);
		}

		public void PopToRoot(bool animated)

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Wrap the page in a LightNavigationPage and pop via that instance.
  2. Branch shared navigation logic by platform, using LightNavigationPage on WPF.
  3. Ensure NavigationProxy resolves to the page-level NavigationPage rather than the global FormsWindow.
  4. Provide a platform-specific INavigation implementation for WPF.

Example fix

// before
await Navigation.PopAsync();

// after
if (Navigation is LightNavigationPage lnp)
    await lnp.PopAsync();
Defensive patterns

Strategy: type-guard

Validate before calling

if (Navigation is LightNavigationPage lnp) await lnp.PopAsync();
else throw new PlatformNotSupportedException("Use LightNavigationPage on WPF.");

Type guard

static bool CanPop(NavigationProxy n) => n is LightNavigationPage;

Try / catch

try { await Navigation.PopAsync(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("LightNavigationPage"))
{ /* wrap page in LightNavigationPage, retry */ }

Prevention

When it happens

Trigger: Calling Navigation.Pop() or Navigation.PopAsync() against the window-level navigation proxy rather than a LightNavigationPage; shared code path that pops without checking platform.

Common situations: Cross-platform code that pops the navigation stack directly; relying on a single Navigation reference that resolves to the window proxy on WPF.

Related errors


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