PrismLibrary/Prism · error · InvalidOperationException
Layout 's Children property is not empty. This control is…
Error message
Layout<View>'s Children property is not empty.
This control is being associated with a region, but the control is already bound to something else.
If you did not explicitly set the control's Children or ItemsSource property,
this exception may be caused by a change in the value of the inherited RegionManager attached property. What it means
Prism.Maui's LayoutViewRegionAdapter binds a region's Views collection to a Layout via BindableLayout. Before adapting, it verifies the Layout does not already have Children or an ItemsSource set; if it does, the control is 'already bound to something else' and the adapter throws InvalidOperationException (Resources.LayoutViewHasChildrenException). This prevents two content sources from fighting over the same control.
Solutions
- Remove all child elements and any BindableLayout.ItemsSource binding from the layout marked with RegionManager.RegionName; let Prism populate it exclusively
- If you need static content plus region views, wrap the region layout inside another container (e.g. a Grid containing a label and an empty StackLayout region)
- Verify no style or attached-property trigger is setting RegionManager.RegionName on a parent container that already has children
- Check that RegionManager.RegionName is not being re-applied/dynamically changed on an already-populated layout
Example fix
// before
<StackLayout RegionManager.RegionName="MyRegion">
<Label Text="Header" />
</StackLayout>
// after
<StackLayout>
<Label Text="Header" />
<StackLayout RegionManager.RegionName="MyRegion" />
</StackLayout> Defensive patterns
Strategy: validation
Validate before calling
bool regionReady = layout is Layout l && !l.Children.Any() && !l.IsSet(BindableLayout.ItemsSourceProperty);
if (!regionReady) throw new InvalidOperationException($"{layout.GetType().Name} must be empty before registering as a region"); Type guard
bool IsUsableAsRegion(Layout layout) => layout is not null && !layout.Children.Any() && !layout.IsSet(BindableLayout.ItemsSourceProperty);
Prevention
- Never declare child elements inside a XAML element marked RegionManager.RegionName
- Keep BindableLayout.ItemsSource unset on region layouts
- Wrap static content in a parent container and place an empty region layout alongside it
When it happens
Trigger: Calling RegionManager.RegisterRegions / region registration (via RegionManager.RegionName attached property) on a Layout (StackLayout, Grid, FlexLayout, etc.) that already has child views declared in XAML or code, or that has BindableLayout.ItemsSource set. Also occurs when the RegionManager.RegionName attached property value changes and re-adaptation is attempted on a populated layout.
Common situations: Declaring <StackLayout RegionManager.RegionName="MyRegion"><Label .../></StackLayout> in XAML — the Label children trigger the throw. Setting ItemsSource on the same layout that is marked as a region. Migrating from Xamarin.Forms Prism where nested content was allowed.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- ScrollView's Content property is not empty. This…
- NavigationException.ErrorCreatingPage
- regionName
- regionTarget
- The object must be of type
AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15).
Data as JSON: /api/errors/b747117ac67f33e0.
Report an issue: GitHub.
Appendix: source
Thrown at src/Maui/Prism.Maui/Navigation/Regions/Adapters/LayoutViewRegionAdapter.cs:35
: base(regionBehaviorFactory)
{
}
/// <summary>
/// Adapts a <see cref="Layout{View}"/> to an <see cref="IRegion"/>.
/// </summary>
/// <param name="region">The new region being used.</param>
/// <param name="regionTarget">The object to adapt.</param>
protected override void Adapt(IRegion region, Layout<View> regionTarget)
{
ArgumentNullException.ThrowIfNull(region);
ArgumentNullException.ThrowIfNull(regionTarget);
bool itemsSourceIsSet = regionTarget.Children?.Any() ?? false || regionTarget.IsSet(BindableLayout.ItemsSourceProperty);
if (itemsSourceIsSet)
{
throw new InvalidOperationException(Resources.LayoutViewHasChildrenException);
}
BindableLayout.SetItemsSource(regionTarget, region.Views);
BindableLayout.SetItemTemplate(regionTarget, new RegionItemsSourceTemplate());
}
/// <summary>
/// Creates a new instance of <see cref="IRegion"/>.
/// </summary>
/// <returns>A new instance of <see cref="Region"/>.</returns>
protected override IRegion CreateRegion(IContainerProvider container) =>
container.Resolve<Region>();
}
View on GitHub (pinned to 358118cd64)