{"record":{"id":"065df27dce018270","repo":"dotnet/maui","slug":"content-not-found-for-active-shell-currentitem","errorCode":null,"errorMessage":"Content not found for active {Shell.CurrentItem}. Title: {Shell.CurrentItem.Title}. Route: {Shell.CurrentItem.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/ShellRenderer.cs","lineNumber":371,"sourceCode":"\n\t\tprotected virtual void UpdateBackgroundColor()\n\t\t{\n\t\t\tvar color = Shell.BackgroundColor?.ToPlatform();\n\t\t\tif (color == null)\n\t\t\t\tcolor = Microsoft.Maui.Platform.ColorExtensions.BackgroundColor;\n\n\t\t\tFlyoutRenderer.View.BackgroundColor = color;\n\t\t}\n\n\t\tvoid SetupCurrentShellItem()\n\t\t{\n\t\t\tif (Shell.CurrentItem == null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\"Active Shell Item not set. Have you added any Shell Items to your Shell?\");\n\t\t\t}\n\t\t\telse if (Shell.CurrentItem.CurrentItem == null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException($\"Content not found for active {Shell.CurrentItem}. Title: {Shell.CurrentItem.Title}. Route: {Shell.CurrentItem.Route}.\");\n\t\t\t}\n\t\t\telse if (_currentShellItemRenderer == null)\n\t\t\t{\n\t\t\t\tOnCurrentItemChanged();\n\t\t\t}\n\t\t}\n\n\t\tbool IViewHandler.HasContainer { get => false; set { } }\n\n\t\tobject IViewHandler.ContainerView => null;\n\n\t\tIView IViewHandler.VirtualView => Element;\n\n\t\tobject IElementHandler.PlatformView => NativeView;\n\n\t\tMaui.IElement IElementHandler.VirtualView => Element;\n\n\t\tIMauiContext IElementHandler.MauiContext => _mauiContext;","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellRenderer.cs#L353-L389","documentation":"Thrown by the iOS ShellRenderer.SetupCurrentShellItem when Shell.CurrentItem exists but Shell.CurrentItem.CurrentItem is null. Shell.CurrentItem is a ShellItem, and ShellItem.CurrentItem is the active ShellContent within that item. If the ShellItem has no selected ShellContent, the renderer cannot proceed. This is the second check in the SetupCurrentShellItem cascade (after the null-ShellItem check).","triggerScenarios":"At line 371: `else if (Shell.CurrentItem.CurrentItem == null) throw`. Triggered when Shell.CurrentItem is a valid ShellItem but that item has no ShellContent selected (CurrentItem is null). This happens when: (1) the active ShellItem has no ShellContent children; (2) ShellContent was removed; (3) CurrentItem auto-selection within the ShellItem failed.","commonSituations":"1) ShellItem defined in XAML without any ShellContent children. 2) ShellItem whose ShellContent DataTemplate failed to instantiate. 3) Dynamic removal of the only ShellContent from the active ShellItem. 4) Shell structure where ShellItem contains only nested ShellItems (unusual/invalid structure). 5) Migration issues where ShellContent auto-generation differs from Xamarin.Forms.","solutions":["Ensure the active ShellItem has at least one ShellContent child with a valid Content or ContentTemplate.","Set ShellItem.CurrentItem explicitly to a ShellContent when building items in code.","Verify the XAML hierarchy: Shell > ShellItem > ShellContent is fully populated.","Inspect the Title and Route from the error message to identify the specific ShellItem missing content.","Test ShellContent DataTemplate resolution independently."],"exampleFix":"<!-- before -->\n<ShellItem Title=\"Settings\">\n  <!-- no ShellContent here -->\n</ShellItem>\n\n<!-- after -->\n<ShellItem Title=\"Settings\">\n  <ShellContent Title=\"Settings\" ContentTemplate=\"{DataTemplate local:SettingsPage}\" Route=\"settings\"/>\n</ShellItem>","handlingStrategy":"validation","validationCode":"// Verify ShellItem has content on iOS\nif (Shell.CurrentItem?.CurrentItem == null)\n    throw new InvalidOperationException(\"Active ShellItem has no ShellContent.\");","typeGuard":"public static bool ShellItemHasActiveContent(ShellItem item)\n    => item?.CurrentItem != null;","tryCatchPattern":null,"preventionTips":["Ensure the active ShellItem has at least one ShellContent child.","Validate the full hierarchy: Shell.CurrentItem.CurrentItem != null.","Set ShellItem.CurrentItem explicitly when building items dynamically."],"tags":["maui","ios","shell","renderer"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}