{"record":{"id":"74555f16a9b6c6fc","repo":"dotnet/maui","slug":"content-not-found-for-active-shellitem-title","errorCode":null,"errorMessage":"Content not found for active {ShellItem}. Title: {ShellItem.Title}. Route: {ShellItem.Route}.","messagePattern":"Content not found for active (.+?)\\. Title: (.+?)\\. Route: (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRenderer.cs","lineNumber":85,"sourceCode":"\n\t\tpublic ShellItemRenderer(IShellContext shellContext) : base(shellContext)\n\t\t{\n\t\t}\n\n\t\tpublic override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)\n\t\t{\n\t\t\tbase.OnCreateView(inflater, container, savedInstanceState);\n\n\t\t\tvar context = MauiContext.Context;\n\t\t\t_outerLayout = PlatformInterop.CreateNavigationBarOuterLayout(context);\n\t\t\t_navigationArea = PlatformInterop.CreateNavigationBarArea(context, _outerLayout);\n\t\t\t_bottomView = PlatformInterop.CreateNavigationBar(context, Resource.Attribute.bottomNavigationViewStyle, _outerLayout, this);\n\n\t\t\tif (ShellItem is null)\n\t\t\t\tthrow new InvalidOperationException(\"Active Shell Item not set. Have you added any Shell Items to your Shell?\");\n\n\t\t\tif (ShellItem.CurrentItem is null)\n\t\t\t\tthrow new InvalidOperationException($\"Content not found for active {ShellItem}. Title: {ShellItem.Title}. Route: {ShellItem.Route}.\");\n\n\t\t\tHookEvents(ShellItem);\n\t\t\tSetupMenu();\n\n\t\t\t_appearanceTracker = ShellContext.CreateBottomNavViewAppearanceTracker(ShellItem);\n\t\t\t_bottomNavigationTracker = new BottomNavigationViewTracker();\n\t\t\t((IShellController)ShellContext.Shell).AddAppearanceObserver(this, ShellItem);\n\n\t\t\treturn _outerLayout;\n\t\t}\n\n\n\t\tvoid Destroy()\n\t\t{\n\t\t\tif (ShellItem is not null)\n\t\t\t\tUnhookEvents(ShellItem);\n\n\t\t\t((IShellController)ShellContext?.Shell)?.RemoveAppearanceObserver(this);","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRenderer.cs#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar item = new ShellItem { Title = \"Home\" };\n// no ShellContent added\nshell.Items.Add(item);\n\n// after\nvar item = new ShellItem { Title = \"Home\" };\nvar content = new ShellContent\n{\n    ContentTemplate = new DataTemplate(() => new HomePage()),\n    Route = \"home\"\n};\nitem.Items.Add(content);\nitem.CurrentItem = content;\nshell.Items.Add(item);","handlingStrategy":"validation","validationCode":"// Verify ShellItem has content before it renders\nforeach (var item in Shell.Items)\n{\n    if (item.CurrentItem == null)\n        throw new InvalidOperationException($\"ShellItem '{item.Title}' has no ShellContent.\");\n}","typeGuard":"public static bool ShellItemHasContent(ShellItem item)\n    => item?.CurrentItem != null && item.Items.Count > 0;","tryCatchPattern":null,"preventionTips":["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."],"tags":["maui","android","shell","renderer","fragment"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}