{"record":{"id":"b79ff78287bac4bd","repo":"dotnet/maui","slug":"content-not-found-for-active-shellsection-title","errorCode":null,"errorMessage":"Content not found for active {shellSection}. Title: {shellSection.Title}. Route: {shellSection.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/ShellSectionRenderer.cs","lineNumber":102,"sourceCode":"\t\tprotected IShellContext ShellContext => _shellContext;\n\t\tIShellSectionController SectionController => (IShellSectionController)ShellSection;\n\t\tIMauiContext MauiContext => ShellContext.Shell.Handler.MauiContext;\n\t\tToolbar _shellToolbar;\n\n\t\tpublic ShellSectionRenderer(IShellContext shellContext)\n\t\t{\n\t\t\t_shellContext = shellContext;\n\t\t}\n\n\n\t\tpublic override AView OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)\n\t\t{\n\t\t\tvar shellSection = ShellSection;\n\t\t\tif (shellSection == null)\n\t\t\t\treturn null;\n\n\t\t\tif (shellSection.CurrentItem == null)\n\t\t\t\tthrow new InvalidOperationException($\"Content not found for active {shellSection}. Title: {shellSection.Title}. Route: {shellSection.Route}.\");\n\n\t\t\tvar context = Context;\n\t\t\tvar root = PlatformInterop.CreateShellCoordinatorLayout(context);\n\t\t\tvar appbar = PlatformInterop.CreateShellAppBar(context, Resource.Attribute.appBarLayoutStyle, root);\n\n\t\t\tMauiWindowInsetListener.SetupViewWithLocalListener(root);\n\n\t\t\tint actionBarHeight = context.GetActionBarHeight();\n\n\t\t\t_shellToolbar = new Toolbar(shellSection);\n\t\t\tShellToolbarTracker.ApplyToolbarChanges(_shellContext.Shell.Toolbar, _shellToolbar);\n\t\t\t_toolbar = (AToolbar)_shellToolbar.ToPlatform(_shellContext.Shell.FindMauiContext());\n\t\t\tappbar.AddView(_toolbar);\n\t\t\t_tablayout = PlatformInterop.CreateShellTabLayout(context, appbar, actionBarHeight);\n\n\t\t\tvar pagerContext = MauiContext.MakeScoped(layoutInflater: inflater, fragmentManager: ChildFragmentManager);\n\t\t\tvar adapter = new ShellFragmentStateAdapter(shellSection, ChildFragmentManager, pagerContext);\n\t\t\tvar pageChangedCallback = new ViewPagerPageChanged(this);","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellSectionRenderer.cs#L84-L120","documentation":"Thrown by the Android ShellSectionRenderer.OnCreateView when ShellSection.CurrentItem is null. A ShellSection (which represents a tab or section within a ShellItem) must have a currently selected ShellContent to display. If CurrentItem is null, the renderer cannot create the page view. The message includes Title and Route for diagnosis.","triggerScenarios":"At line 102: `if (shellSection.CurrentItem == null) throw`. Occurs during the Android Fragment's OnCreateView lifecycle when the ShellSection bound to this renderer fragment has no active ShellContent. This happens when: (1) ShellSection was created without ShellContent children; (2) CurrentItem was set to null; (3) ShellContent was removed dynamically; (4) routing failed to select a ShellContent.","commonSituations":"1) ShellSection defined in XAML with no ShellContent children. 2) Dynamic removal of the only ShellContent from a ShellSection while the fragment is active. 3) ShellSection created in code without adding ShellContent. 4) Route-based navigation that lands on an empty ShellSection. 5) Tab/Flyout structure where a ShellSection is referenced but its content was never defined.","solutions":["Ensure every ShellSection has at least one ShellContent child with a valid Content or ContentTemplate.","When creating ShellSections dynamically, add ShellContent and set CurrentItem before navigation triggers rendering.","Verify the XAML hierarchy: Shell > ShellItem > ShellSection > ShellContent (each level must be populated).","Check that route navigation targets a ShellContent, not an empty ShellSection.","Use the Title/Route from the error message to locate the specific misconfigured ShellSection."],"exampleFix":"// before\nvar section = new ShellSection { Title = \"Tab1\" };\n// no ShellContent added\nitem.Items.Add(section);\n\n// after\nvar section = new ShellSection { Title = \"Tab1\" };\nsection.Items.Add(new ShellContent\n{\n    ContentTemplate = new DataTemplate(() => new TabPage1()),\n    Route = \"tab1\"\n});\nitem.Items.Add(section);","handlingStrategy":"validation","validationCode":"// Verify ShellSection has content before navigation\nforeach (var section in shellItem.Items.OfType<ShellSection>())\n{\n    if (section.CurrentItem == null)\n        throw new InvalidOperationException($\"ShellSection '{section.Title}' has no ShellContent.\");\n}","typeGuard":"public static bool ShellSectionHasContent(ShellSection section)\n    => section?.CurrentItem != null && section.Items.Count > 0;","tryCatchPattern":null,"preventionTips":["Ensure every ShellSection has at least one ShellContent child.","Validate the full Shell hierarchy (Shell > ShellItem > ShellSection > ShellContent) at startup.","Set ShellSection.CurrentItem explicitly in code."],"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"}