dotnet/maui · error · InvalidOperationException
Implement INativeElementView on cell renderer: {ContentCell.
Error message
Implement INativeElementView on cell renderer: {ContentCell.GetType().AssemblyQualifiedName} What it means
Thrown by the iOS ContextActionCell.Element getter when ContentCell does not implement INativeElementView. Context actions need to reach the underlying Cell element through this interface; a custom/legacy cell renderer lacking it cannot supply context actions.
Source
Thrown at src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ContextActionCell.cs:71
public ContextActionsCell(string templateId) : base(UITableViewCellStyle.Default, Key + templateId)
{
}
public UITableViewCell ContentCell { get; private set; }
public bool IsOpen => ScrollDelegate.IsOpen;
ContextScrollViewDelegate ScrollDelegate => (ContextScrollViewDelegate)_scroller.Delegate;
Element INativeElementView.Element
{
get
{
var boxedCell = ContentCell as INativeElementView;
if (boxedCell == null)
{
throw new InvalidOperationException($"Implement {nameof(INativeElementView)} on cell renderer: {ContentCell.GetType().AssemblyQualifiedName}");
}
return boxedCell.Element;
}
}
public void Close()
{
if (_scroller == null)
return;
_scroller.ContentOffset = new PointF(0, 0);
}
static void FillRect(UIGraphicsImageRendererContext ctx, RectangleF rect, CGColor color)
{
var context = ctx.CGContext;
context.SetFillColor(color);View on GitHub (pinned to f377ff1c5e)
Solutions
- Use a built-in cell type (TextCell, SwitchCell, ViewCell) whose renderer implements INativeElementView.
- Update the custom cell renderer so its platform view implements INativeElementView and returns the Cell.
- Remove context actions from cells whose renderers cannot satisfy the contract.
Example fix
// before
<TableView>
<TableRoot>
<TableSection>
<MyLegacyCustomCell>
<ViewCell.ContextActions>
<MenuItem Text="Delete" />
</ViewCell.ContextActions>
</MyLegacyCustomCell>
</TableSection>
</TableRoot>
</TableView>
// after — use built-in TextCell which supports context actions
<TextCell Text="Item">
<TextCell.ContextActions>
<MenuItem Text="Delete" />
</TextCell.ContextActions>
</TextCell> Defensive patterns
Strategy: validation
Validate before calling
// Use a built-in cell type whose renderer implements INativeElementView
if (!(contentCell is INativeElementView))
throw new InvalidOperationException($"{contentCell.GetType()} cannot host context actions; use a built-in cell."); Type guard
static bool SupportsContextActions(Cell c) =>
c.ToHandler(c.FindMauiContext())?.PlatformView is INativeElementView; Prevention
- Use built-in cell types (TextCell, ViewCell) for context actions.
- Ensure custom iOS cell renderers implement INativeElementView.
- Avoid context actions on legacy/third-party cells.
When it happens
Trigger: Attaching context actions to a cell whose platform renderer does not implement INativeElementView. Using a custom iOS cell renderer that returns a plain UITableViewCell. Mixing a legacy cell with the MAUI context-action pipeline.
Common situations: Porting a Xamarin.Forms iOS custom cell renderer. Third-party cell renderers that bypass the INativeElementView contract. Enabling context actions on a cell type whose renderer was never updated for MAUI.
Related errors
- View for cell must implement INativeElementView to enable re
- No UIViewController found to present.
- Header cells do not support context actions
- Implement INativeElementView on cell renderer: {ContentCell.
- No UIViewController found to present.
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/a2528f4ae82d4f04.
Report an issue: GitHub.