dotnet/maui · error · InvalidOperationException
Content not found for active {ShellItem}. Title: {ShellItem.
Error message
Content not found for active {ShellItem}. Title: {ShellItem.Title}. Route: {ShellItem.Route}. What it means
Thrown by Android ShellItemRenderer.OnCreateView when ShellItem is non-null but ShellItem.CurrentItem is null. ShellItem.CurrentItem is the active ShellContent (the page content) within that ShellItem. Even though a ShellItem exists, it has no child ShellContent selected, meaning the renderer cannot determine which page to display. The message includes the ShellItem's Title and Route for diagnostics.
Source
Thrown at src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRenderer.cs:85
public ShellItemRenderer(IShellContext shellContext) : base(shellContext)
{
}
public override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
base.OnCreateView(inflater, container, savedInstanceState);
var context = MauiContext.Context;
_outerLayout = PlatformInterop.CreateNavigationBarOuterLayout(context);
_navigationArea = PlatformInterop.CreateNavigationBarArea(context, _outerLayout);
_bottomView = PlatformInterop.CreateNavigationBar(context, Resource.Attribute.bottomNavigationViewStyle, _outerLayout, this);
if (ShellItem is null)
throw new InvalidOperationException("Active Shell Item not set. Have you added any Shell Items to your Shell?");
if (ShellItem.CurrentItem is null)
throw new InvalidOperationException($"Content not found for active {ShellItem}. Title: {ShellItem.Title}. Route: {ShellItem.Route}.");
HookEvents(ShellItem);
SetupMenu();
_appearanceTracker = ShellContext.CreateBottomNavViewAppearanceTracker(ShellItem);
_bottomNavigationTracker = new BottomNavigationViewTracker();
((IShellController)ShellContext.Shell).AddAppearanceObserver(this, ShellItem);
return _outerLayout;
}
void Destroy()
{
if (ShellItem is not null)
UnhookEvents(ShellItem);
((IShellController)ShellContext?.Shell)?.RemoveAppearanceObserver(this);View on GitHub (pinned to f377ff1c5e)
Solutions
- Ensure every ShellItem contains at least one ShellContent with a valid ContentTemplate or Content page.
- When adding items dynamically, set ShellItem.CurrentItem explicitly after adding ShellContent children.
- Verify route registrations (Routing.RegisterRoute) match the ShellContent Route values.
- Check that ShellContent's ContentTemplate DataTemplate resolves to a non-null Page.
- Inspect the ShellItem.Title and ShellItem.Route from the error message to identify which item is malformed.
Example fix
// before
var item = new ShellItem { Title = "Home" };
// no ShellContent added
shell.Items.Add(item);
// after
var item = new ShellItem { Title = "Home" };
var content = new ShellContent
{
ContentTemplate = new DataTemplate(() => new HomePage()),
Route = "home"
};
item.Items.Add(content);
item.CurrentItem = content;
shell.Items.Add(item); Defensive patterns
Strategy: validation
Validate before calling
// Verify ShellItem has content before it renders
foreach (var item in Shell.Items)
{
if (item.CurrentItem == null)
throw new InvalidOperationException($"ShellItem '{item.Title}' has no ShellContent.");
} Type guard
public static bool ShellItemHasContent(ShellItem item)
=> item?.CurrentItem != null && item.Items.Count > 0; Prevention
- Ensure every ShellItem has at least one ShellContent with a valid ContentTemplate.
- Set ShellItem.CurrentItem explicitly when creating items in code.
- Validate Shell hierarchy in a startup/initialization method.
When it happens
Trigger: At line 85: `if (ShellItem.CurrentItem is null) throw`. Triggered when a ShellItem has been created but has no ShellContent children, or its CurrentItem was explicitly set to null. This can happen with a ShellItem that only contains Tabs/ShellSections that themselves are empty, or when the ShellContent was removed dynamically.
Common situations: 1) A ShellItem defined with no ShellContent children: `<ShellItem><ShellSection/></ShellItem>` but the ShellSection has no ShellContent. 2) Dynamic removal of the active ShellContent while the fragment is being created. 3) Routing to a ShellItem whose ShellContent failed to resolve (route mismatch or DataTemplate returning null). 4) ShellItem with items added at runtime but CurrentItem not auto-selected.
Related errors
- Active Shell Item not set. Have you added any Shell Items to
- Content not found for active {shellSection}. Title: {shellSe
- Unexpected navigation type
- LoadView must be called before accessing View
- Shell Content Page is Null
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/74555f16a9b6c6fc.
Report an issue: GitHub.