{"record":{"id":"159c484c266703cc","repo":"dotnet/maui","slug":"content-not-found-for-active-shellitem-title-159c48","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/iOS/ShellItemRenderer.cs","lineNumber":412,"sourceCode":"\t\t{\n\t\t\tconst int maxTabs = 5;\n\t\t\tvar currentViewControllers = ViewControllers;\n\t\t\tif (currentViewControllers == null)\n\t\t\t\treturn;\n\n\t\t\tbool willUseMore = currentViewControllers.Length > maxTabs;\n\t\t\tfor (int i = 0; i < currentViewControllers.Length; i++)\n\t\t\t{\n\t\t\t\tvar renderer = RendererForViewController(currentViewControllers[i]);\n\t\t\t\tif (renderer != null)\n\t\t\t\t\trenderer.IsInMoreTab = willUseMore && i >= maxTabs - 1;\n\t\t\t}\n\t\t}\n\n\t\tvoid CreateTabRenderers()\n\t\t{\n\t\t\tif (ShellItem.CurrentItem == null)\n\t\t\t\tthrow new InvalidOperationException($\"Content not found for active {ShellItem}. Title: {ShellItem.Title}. Route: {ShellItem.Route}.\");\n\n\t\t\tvar items = ShellItemController.GetItems();\n\t\t\tvar count = items.Count;\n\t\t\tint maxTabs = 5; // fetch this a better way\n\t\t\tbool willUseMore = count > maxTabs;\n\n\t\t\tUIViewController[] viewControllers = new UIViewController[count];\n\t\t\tint i = 0;\n\t\t\tforeach (var shellContent in items)\n\t\t\t{\n\t\t\t\tvar renderer = _context.CreateShellSectionRenderer(shellContent);\n\n\t\t\t\trenderer.IsInMoreTab = willUseMore && i >= maxTabs - 1;\n\n\t\t\t\trenderer.ShellSection = shellContent;\n\t\t\t\tAddRenderer(renderer);\n\t\t\t\tviewControllers[i++] = renderer.ViewController;\n\t\t\t}","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs#L394-L430","documentation":"Thrown by the iOS ShellItemRenderer.CreateTabRenderers when ShellItem.CurrentItem is null. On iOS, the ShellItemRenderer builds UITabBarController view controllers for each ShellContent. If the active ShellContent (CurrentItem) is null, it cannot determine what to display. This mirrors the Android counterpart (error 444) but in the iOS renderer.","triggerScenarios":"At line 412: `if (ShellItem.CurrentItem == null) throw`. Called during CreateTabRenderers which builds the UIViewController array for the tab bar. Triggered when a ShellItem exists but has no ShellContent selected as CurrentItem — either no children exist, or CurrentItem was explicitly nulled or not auto-selected.","commonSituations":"1) ShellItem with zero ShellContent children. 2) ShellContent removed at runtime. 3) Shell defined in XAML with structural issues (ShellItem without ShellContent). 4) Auto-selection of CurrentItem failed due to routing or binding errors. 5) Migration from Xamarin.Forms where CurrentItem auto-selection timing differs.","solutions":["Ensure ShellItem has at least one ShellContent child with a valid page.","Set ShellItem.CurrentItem explicitly when building items dynamically.","Verify XAML hierarchy completeness: ShellItem must contain ShellContent (directly or via ShellSection/Tab).","Check DataTemplate/Content resolution for ShellContent.","Use the Title/Route from the error to identify the problematic ShellItem."],"exampleFix":"<!-- before: ShellItem with no content -->\n<ShellItem Title=\"Home\">\n</ShellItem>\n\n<!-- after -->\n<ShellItem Title=\"Home\">\n  <ShellContent Title=\"Home\" ContentTemplate=\"{DataTemplate local:HomePage}\" Route=\"home\"/>\n</ShellItem>","handlingStrategy":"validation","validationCode":"// Verify ShellItem has content before iOS renderer builds tabs\nif (shellItem.CurrentItem == null)\n    throw new InvalidOperationException($\"ShellItem '{shellItem.Title}' has no ShellContent.\");","typeGuard":"public static bool ShellItemHasContent(ShellItem item)\n    => item?.CurrentItem != null && item.Items.Count > 0;","tryCatchPattern":null,"preventionTips":["Ensure ShellItem always has at least one ShellContent child with a valid page.","Validate Shell hierarchy on both iOS and Android during testing.","Set ShellItem.CurrentItem explicitly when building items dynamically."],"tags":["maui","ios","shell","renderer","uiviewcontroller"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}