dotnet/maui · error · NotSupportedException
Unknown cell parent type
Error message
Unknown cell parent type
What it means
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.
Source
Thrown at src/Controls/src/Core/Compatibility/iOS/Extensions/CellExtensions.cs:36
#pragma warning disable CS0618 // Type or member is obsolete
if (self.RealParent is ListView)
{
var section = 0;
var til = self.GetGroup<ItemsView<Cell>, Cell>();
if (til != null)
section = til.HeaderContent.GetIndex<ItemsView<Cell>, Cell>();
var row = self.GetIndex<ItemsView<Cell>, Cell>();
path = NSIndexPath.FromRowSection(row, section);
}
else if (self.RealParent is TableView)
{
var tmPath = self.GetPath();
path = NSIndexPath.FromRowSection(tmPath.Item2, tmPath.Item1);
}
else
throw new NotSupportedException("Unknown cell parent type");
#pragma warning restore CS0618 // Type or member is obsolete
return path;
}
}
}View on GitHub (pinned to f377ff1c5e)
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.
Example fix
// before
var cell = new TextCell { Text = "Hello" };
var stack = new StackLayout();
stack.Children.Add(cell); // Cell in a non-list container — throws on index lookup
// after
var label = new Label { Text = "Hello" };
var stack = new StackLayout();
stack.Children.Add(label);
// or use Cell only within a ListView:
var listView = new ListView
{
ItemTemplate = new DataTemplate(() =>
{
var cell = new TextCell();
cell.SetBinding(TextCell.TextProperty, "Name");
return cell;
})
}; Defensive patterns
Strategy: type-guard
Validate before calling
// Verify parent is a supported container type
if (cell.RealParent is not ListView && cell.RealParent is not TableView)
throw new NotSupportedException("Cell parent must be ListView or TableView."); Type guard
public static bool IsCellInValidContainer(Cell cell)
=> cell?.RealParent is ListView or TableView; Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Implement INativeElementView on cell renderer: {ContentCell.
- No UIViewController found to present.
- Index '{Math.Max(e.NewStartingIndex, e.OldStartingIndex)}' i
- Header cells do not support context actions
- ViewCell must have a View
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/cd66953c1f68ecb4.
Report an issue: GitHub.