dotnet/maui · error · InvalidOperationException

Title property must be set on Flyout page

Error message

Title property must be set on Flyout page

What it means

FlyoutPage.Flyout setter throws InvalidOperationException when the supplied Page has an empty Title. Platform flyout surfaces (drawer header, split master pane, menu items) require a title to render and for accessibility; the guard at FlyoutPage.cs:118 enforces this before any other check.

Source

Thrown at src/Controls/src/Core/FlyoutPage/FlyoutPage.cs:118

		/// <summary>Gets or sets a value that indicates whether the flyout is presented. This is a bindable property.</summary>
		public bool IsPresented
		{
			get { return (bool)GetValue(IsPresentedProperty); }
			set { SetValue(IsPresentedProperty, BooleanBoxes.Box(value)); }
		}

		/// <summary>Gets or sets the flyout page that is used to present a menu or navigation options.</summary>
		public Page Flyout
		{
			get { return _flyout; }
			set
			{
				if (_flyout != null && value == null)
					throw new ArgumentNullException(nameof(value), "Flyout cannot be set to null once a value is set");

				if (string.IsNullOrEmpty(value.Title))
					throw new InvalidOperationException("Title property must be set on Flyout page");

				if (_flyout == value)
					return;

				if (value.RealParent != null)
					throw new InvalidOperationException("Flyout must not already have a parent.");

				// TODO MAUI refine this to fire earlier
				var previousFlyout = _flyout;
				
				// TODO MAUI refine this to fire earlier
				previousFlyout?.SendNavigatingFrom(new NavigatingFromEventArgs(value, NavigationType.Replace));

				OnPropertyChanging();
				if (_flyout != null)
					InternalChildren.Remove(_flyout);
				_flyout = value;
				InternalChildren.Add(_flyout);

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Set `page.Title = "Menu";` before assigning to Flyout.
  2. Ensure the bound Title source is non-empty at assignment time (initialize the model property).
  3. Use a FallbackValue in the Title binding to guarantee a non-empty string.

Example fix

// before
flyoutPage.Flyout = new ContentPage(); // Title empty

// after
flyoutPage.Flyout = new ContentPage { Title = "Menu" };
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(page.Title)) page.Title = "Menu"; flyoutPage.Flyout = page;

Type guard

static bool HasTitle(Page p) => !string.IsNullOrEmpty(p.Title);

Try / catch

try { flyoutPage.Flyout = page; } catch (InvalidOperationException) { page.Title = "Menu"; flyoutPage.Flyout = page; }

Prevention

When it happens

Trigger: Assigning a Page whose Title is null or empty string to FlyoutPage.Flyout. Note the check fires even if the new value equals the current Flyout, so re-assigning the same untitled page still throws.

Common situations: Building the flyout page programmatically and forgetting to set Title, binding Title to a model property that is initially null, or reusing a ContentPage default-constructed.

Related errors


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