{"record":{"id":"cd66953c1f68ecb4","repo":"dotnet/maui","slug":"unknown-cell-parent-type","errorCode":null,"errorMessage":"Unknown cell parent type","messagePattern":"Unknown cell parent type","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/Compatibility/iOS/Extensions/CellExtensions.cs","lineNumber":36,"sourceCode":"\n#pragma warning disable CS0618 // Type or member is obsolete\n\t\t\tif (self.RealParent is ListView)\n\t\t\t{\n\t\t\t\tvar section = 0;\n\t\t\t\tvar til = self.GetGroup<ItemsView<Cell>, Cell>();\n\t\t\t\tif (til != null)\n\t\t\t\t\tsection = til.HeaderContent.GetIndex<ItemsView<Cell>, Cell>();\n\n\t\t\t\tvar row = self.GetIndex<ItemsView<Cell>, Cell>();\n\t\t\t\tpath = NSIndexPath.FromRowSection(row, section);\n\t\t\t}\n\t\t\telse if (self.RealParent is TableView)\n\t\t\t{\n\t\t\t\tvar tmPath = self.GetPath();\n\t\t\t\tpath = NSIndexPath.FromRowSection(tmPath.Item2, tmPath.Item1);\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new NotSupportedException(\"Unknown cell parent type\");\n#pragma warning restore CS0618 // Type or member is obsolete\n\n\t\t\treturn path;\n\t\t}\n\t}\n}","sourceCodeStart":18,"sourceCodeEnd":42,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/iOS/Extensions/CellExtensions.cs#L18-L42","documentation":"Thrown by the iOS CellExtensions.GetIndexPath when a Cell's RealParent is neither a ListView (ItemsView<Cell>) nor a TableView. The extension method determines the NSIndexPath (row/section) for a cell in a UITableView, and it only knows how to index cells within ListView or TableView containers. Any other parent type causes NotSupportedException, indicating the cell was added to an unsupported container.","triggerScenarios":"At line 36: the else branch of `if (self.RealParent is ItemsView<Cell>)` / `else if (self.RealParent is TableView)` throws. Triggered when a Cell's RealParent is some other type — not a ListView or TableView. This could happen when: (1) a Cell is used outside of a ListView/TableView context (e.g., as a standalone element); (2) a custom layout or container tries to host a Cell directly; (3) the cell's parent reference was reassigned to a non-list container; (4) a CellView or custom cell-based component misuses the Cell API.","commonSituations":"1) Using a Cell type (TextCell, SwitchCell, etc.) outside of ListView or TableView — e.g., placing it directly in a StackLayout. 2) Custom controls that inherit from Cell and are hosted in non-standard containers. 3) Migration from Xamarin.Forms where a Cell was used in a context that the MAUI compatibility layer doesn't support. 4) Third-party libraries that repurpose Cell objects in non-list contexts.","solutions":["Only use Cell types within ListView or TableView — for standalone UI, use ContentView or other layout elements instead.","If displaying cell-like content outside a list, create a ContentView with equivalent layout rather than reusing Cell.","Verify that any custom Cell subclasses are only added to ListView.ItemTemplate or TableView.Root.","If building a custom list/grid, use CollectionView with DataTemplate (the modern MAUI approach) rather than the legacy Cell-based ListView/TableView.","Check that no code path reassigns a Cell's parent to a non-list element."],"exampleFix":"// before\nvar cell = new TextCell { Text = \"Hello\" };\nvar stack = new StackLayout();\nstack.Children.Add(cell); // Cell in a non-list container — throws on index lookup\n\n// after\nvar label = new Label { Text = \"Hello\" };\nvar stack = new StackLayout();\nstack.Children.Add(label);\n\n// or use Cell only within a ListView:\nvar listView = new ListView\n{\n    ItemTemplate = new DataTemplate(() =>\n    {\n        var cell = new TextCell();\n        cell.SetBinding(TextCell.TextProperty, \"Name\");\n        return cell;\n    })\n};","handlingStrategy":"type-guard","validationCode":"// Verify parent is a supported container type\nif (cell.RealParent is not ListView && cell.RealParent is not TableView)\n    throw new NotSupportedException(\"Cell parent must be ListView or TableView.\");","typeGuard":"public static bool IsCellInValidContainer(Cell cell)\n    => cell?.RealParent is ListView or TableView;","tryCatchPattern":null,"preventionTips":["Only use Cell types within ListView or TableView.","For standalone UI elements outside lists, use ContentView or Label directly.","Prefer CollectionView with DataTemplate over legacy Cell-based ListView."],"tags":["maui","ios","cell","listview","tableview","compatibility"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}