{"record":{"id":"e9195c99c69e6912","repo":"dotnet/maui","slug":"content-not-found-for-active-shellsection-title-e9195c","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/iOS/ShellSectionRootRenderer.cs","lineNumber":111,"sourceCode":"\t\t{\n\t\t\tbase.TraitCollectionDidChange(previousTraitCollection);\n\t\t\tif (previousTraitCollection?.VerticalSizeClass != TraitCollection.VerticalSizeClass ||\n\t\t\t\tpreviousTraitCollection?.HorizontalSizeClass != TraitCollection.HorizontalSizeClass)\n\t\t\t{\n\t\t\t\tif (OperatingSystem.IsIOSVersionAtLeast(26) || OperatingSystem.IsMacCatalystVersionAtLeast(26))\n\t\t\t\t{\n\t\t\t\t\t(_tracker as ShellPageRendererTracker)?.UpdateTitleViewFrameForOrientation();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic override void ViewDidLoad()\n\t\t{\n\t\t\tif (_isDisposed)\n\t\t\t\treturn;\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\tbase.ViewDidLoad();\n\n\t\t\t_containerArea = new UIView();\n\t\t\tif (OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsMacCatalystVersionAtLeast(11)\n#if TVOS\n\t\t\t\t|| OperatingSystem.IsTvOSVersionAtLeast(11)\n#endif\n\t\t\t)\n\t\t\t{\n\t\t\t\t_containerArea.InsetsLayoutMarginsFromSafeArea = false;\n\t\t\t}\n\n\t\t\tView.AddSubview(_containerArea);\n\n\t\t\tLoadRenderers();\n\n\t\t\tShellSection.PropertyChanged += OnShellSectionPropertyChanged;","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRootRenderer.cs#L93-L129","documentation":"Thrown by the iOS ShellSectionRootRenderer.ViewDidLoad when ShellSection.CurrentItem is null. The ShellSectionRootRenderer is the UIViewController for a ShellSection's root content on iOS. ViewDidLoad is called once when the view controller's view is first loaded; if the ShellSection has no active ShellContent at that point, the renderer cannot build its content area.","triggerScenarios":"At line 111: `if (ShellSection.CurrentItem == null) throw`. ViewDidLoad is a UIKit lifecycle method. Triggered when: (1) the ShellSection has no ShellContent children; (2) CurrentItem was nulled or not set; (3) the view controller was loaded before content was assigned (timing issue); (4) ShellContent was removed during the section's lifecycle.","commonSituations":"1) ShellSection defined without ShellContent children in XAML. 2) Dynamic removal of ShellContent while the section's view controller is loading. 3) Route-based navigation that lands on an empty ShellSection. 4) ShellSection created programmatically without adding content. 5) Lifecycle timing where ViewDidLoad fires before ShellSection is fully configured.","solutions":["Ensure every ShellSection has at least one ShellContent child before its view controller loads.","When creating sections dynamically, add ShellContent and set CurrentItem before navigation.","Verify XAML structure: ShellSection must contain ShellContent with valid Content/ContentTemplate.","Use the Title/Route from the error to locate the specific ShellSection.","Avoid removing the active ShellContent while the section is visible — switch CurrentItem first."],"exampleFix":"// before\nvar section = new ShellSection { Title = \"Browse\", Route = \"browse\" };\nitem.Items.Add(section);\n// no ShellContent — ViewDidLoad will throw\n\n// after\nvar section = new ShellSection { Title = \"Browse\", Route = \"browse\" };\nsection.Items.Add(new ShellContent\n{\n    ContentTemplate = new DataTemplate(() => new BrowsePage()),\n    Route = \"browsecontent\"\n});\nitem.Items.Add(section);","handlingStrategy":"validation","validationCode":"// Verify ShellSection has content before ViewDidLoad fires\nif (shellSection.CurrentItem == null)\n    throw new InvalidOperationException($\"ShellSection '{shellSection.Title}' has no content.\");","typeGuard":"public static bool ShellSectionHasContent(ShellSection section)\n    => section?.CurrentItem != null;","tryCatchPattern":null,"preventionTips":["Ensure ShellSection has at least one ShellContent before its view controller loads.","Add ShellContent in the constructor or OnInitialized, not after display.","Avoid removing the active ShellContent from a visible ShellSection."],"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"}