{"record":{"id":"5f3d66b27f339d89","repo":"PrismLibrary/Prism","slug":"regiontarget","errorCode":null,"errorMessage":"regionTarget","messagePattern":"regionTarget","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Maui/Prism.Maui/Navigation/Regions/Adapters/LayoutRegionAdapter.cs","lineNumber":31,"sourceCode":"    /// </summary>\n    /// <param name=\"regionBehaviorFactory\">The factory used to create the region behaviors to attach to the created regions.</param>\n    public LayoutRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)\n        : base(regionBehaviorFactory)\n    {\n    }\n\n    /// <summary>\n    /// Adapts a <see cref=\"Layout\"/> to an <see cref=\"IRegion\"/>.\n    /// </summary>\n    /// <param name=\"region\">The new region being used.</param>\n    /// <param name=\"regionTarget\">The object to adapt.</param>\n    protected override void Adapt(IRegion region, Layout regionTarget)\n    {\n        if (region == null)\n            throw new ArgumentNullException(nameof(region));\n\n        if (regionTarget == null)\n            throw new ArgumentNullException(nameof(regionTarget));\n\n        bool itemsSourceIsSet = regionTarget.Children?.Any() ?? false || regionTarget.IsSet(BindableLayout.ItemsSourceProperty);\n\n        if (itemsSourceIsSet)\n        {\n            throw new InvalidOperationException(Resources.LayoutViewHasChildrenException);\n        }\n\n        BindableLayout.SetItemsSource(regionTarget, region.Views);\n        BindableLayout.SetItemTemplate(regionTarget, new RegionItemsSourceTemplate());\n    }\n\n    /// <summary>\n    /// Creates a new instance of <see cref=\"IRegion\"/>.\n    /// </summary>\n    /// <returns>A new instance of <see cref=\"Region\"/>.</returns>\n    protected override IRegion CreateRegion(IContainerProvider container) =>\n        container.Resolve<Region>();","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Maui/Prism.Maui/Navigation/Regions/Adapters/LayoutRegionAdapter.cs#L13-L49","documentation":"LayoutRegionAdapter.Adapt throws ArgumentNullException(nameof(regionTarget)) when the Layout control to be adapted is null. The adapter cannot attach BindableLayout items to a null target, so this is an internal contract violation by the region infrastructure or a custom caller.","triggerScenarios":"Adapt called with a null Layout regionTarget - usually from malformed region registration where the control lookup failed (region name attached to a non-existent control) or a custom adapter invocation.","commonSituations":"XAML region name set on a control that was removed/replaced so the target resolves null; custom code calling the adapter directly; platform-specific layouts that are not real Layout instances.","solutions":["Confirm the XAML element with prism:RegionManager.RegionName actually exists and instantiates on the target platform.","Verify the attached control derives from Layout (the adapter's supported target type).","Fix custom callers to pass a concrete Layout instance to Adapt."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (regionTarget is null) return; // ensure the XAML control resolved on this platform","typeGuard":"bool TryGetTarget(Layout control, out Layout target)\n{\n    target = control;\n    return target != null;\n}","tryCatchPattern":null,"preventionTips":["Ensure the region-named control exists on all platforms' XAML.","Confirm the target control derives from Layout.","Avoid manipulating adapter targets directly; let the region manager resolve them."],"tags":["regions","null-argument","adapter","maui"],"backgroundTag":"null-argument","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}