{"record":{"id":"2b0a04655af1ad0e","repo":"dotnet/maui","slug":"indexpath","errorCode":null,"errorMessage":"indexPath","messagePattern":"indexPath","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/CollectionView/ListSource.cs","lineNumber":38,"sourceCode":"\t\t{\n\t\t\tforeach (object item in enumerable)\n\t\t\t{\n\t\t\t\tAdd(item);\n\t\t\t}\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\n\t\t}\n\n\t\tpublic object this[NSIndexPath indexPath]\n\t\t{\n\t\t\tget\n\t\t\t{\n\t\t\t\tif (indexPath.Section > 0)\n\t\t\t\t{\n\t\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(indexPath));\n\t\t\t\t}\n\n\t\t\t\treturn this[(int)indexPath.Item];\n\t\t\t}\n\t\t}\n\n\t\tpublic int GroupCount => 1;\n\n\t\tpublic int ItemCount => Count;\n\n\t\tpublic NSIndexPath GetIndexForItem(object item)\n\t\t{\n\t\t\tfor (int n = 0; n < Count; n++)\n\t\t\t{\n\t\t\t\tif (this[n] == item)\n\t\t\t\t{\n\t\t\t\t\treturn NSIndexPath.Create(0, n);\n\t\t\t\t}","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/CollectionView/ListSource.cs#L20-L56","documentation":"ListSource is a single-section IItemsViewSource wrapping a plain list. Its indexer rejects any NSIndexPath whose Section is greater than 0, because ListSource only ever holds one section. This protects against a caller handing it a multi-section path that the backing data cannot satisfy.","triggerScenarios":"Accessing ListSource[NSIndexPath] with indexPath.Section > 0; typically an upstream caller that assumes multi-section grouping while ItemsView is bound to a flat non-grouped source.","commonSituations":"Switching a grouped ItemsView layout to a non-grouped one without rebinding; feeding grouped-style index paths from a header/footer supplementary view into a ListSource-backed collection; a custom layout computing paths in section 1+.","solutions":["Bind a GroupedItemsSource / use GroupHeaderTemplate when your data or layout is grouped.","Verify NSIndexPath.Section == 0 before indexing into a non-grouped ItemsViewSource.","Ensure the items layout (Linear/Grid) matches a flat source and only use Grouped layout with group data."],"exampleFix":"// before\nvar item = source[indexPath];\n// after\nif (indexPath.Section == 0)\n    item = source[indexPath];","handlingStrategy":"validation","validationCode":"// Before indexing:\nif (indexPath.Section != 0) return; // ListSource is single-section","typeGuard":"static bool IsSingleSectionPath(NSIndexPath p) => p.Section == 0;","tryCatchPattern":null,"preventionTips":["Keep ItemsLayout flat when using ListSource.","Verify Section == 0 before indexing non-grouped sources.","Do not pass grouped index paths to flat sources."],"tags":["maui","xamarin-forms","ios","uicollectionview","argument-validation","indexpath"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}