{"record":{"id":"a2528f4ae82d4f04","repo":"dotnet/maui","slug":"implement-inativeelementview-on-cell-renderer-co-a2528f","errorCode":null,"errorMessage":"Implement INativeElementView on cell renderer: {ContentCell.GetType().AssemblyQualifiedName}","messagePattern":"Implement INativeElementView on cell renderer: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ContextActionCell.cs","lineNumber":71,"sourceCode":"\n\t\tpublic ContextActionsCell(string templateId) : base(UITableViewCellStyle.Default, Key + templateId)\n\t\t{\n\t\t}\n\n\t\tpublic UITableViewCell ContentCell { get; private set; }\n\n\t\tpublic bool IsOpen => ScrollDelegate.IsOpen;\n\n\t\tContextScrollViewDelegate ScrollDelegate => (ContextScrollViewDelegate)_scroller.Delegate;\n\n\t\tElement INativeElementView.Element\n\t\t{\n\t\t\tget\n\t\t\t{\n\t\t\t\tvar boxedCell = ContentCell as INativeElementView;\n\t\t\t\tif (boxedCell == null)\n\t\t\t\t{\n\t\t\t\t\tthrow new InvalidOperationException($\"Implement {nameof(INativeElementView)} on cell renderer: {ContentCell.GetType().AssemblyQualifiedName}\");\n\t\t\t\t}\n\n\t\t\t\treturn boxedCell.Element;\n\t\t\t}\n\t\t}\n\n\t\tpublic void Close()\n\t\t{\n\t\t\tif (_scroller == null)\n\t\t\t\treturn;\n\n\t\t\t_scroller.ContentOffset = new PointF(0, 0);\n\t\t}\n\n\t\tstatic void FillRect(UIGraphicsImageRendererContext ctx, RectangleF rect, CGColor color)\n\t\t{\n\t\t\tvar context = ctx.CGContext;\n\t\t\tcontext.SetFillColor(color);","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ContextActionCell.cs#L53-L89","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n<TableView>\n  <TableRoot>\n    <TableSection>\n      <MyLegacyCustomCell>\n        <ViewCell.ContextActions>\n          <MenuItem Text=\"Delete\" />\n        </ViewCell.ContextActions>\n      </MyLegacyCustomCell>\n    </TableSection>\n  </TableRoot>\n</TableView>\n\n// after — use built-in TextCell which supports context actions\n<TextCell Text=\"Item\">\n  <TextCell.ContextActions>\n    <MenuItem Text=\"Delete\" />\n  </TextCell.ContextActions>\n</TextCell>","handlingStrategy":"validation","validationCode":"// Use a built-in cell type whose renderer implements INativeElementView\nif (!(contentCell is INativeElementView))\n    throw new InvalidOperationException($\"{contentCell.GetType()} cannot host context actions; use a built-in cell.\");","typeGuard":"static bool SupportsContextActions(Cell c) =>\n    c.ToHandler(c.FindMauiContext())?.PlatformView is INativeElementView;","tryCatchPattern":null,"preventionTips":["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."],"tags":["maui","listview","ios","context-actions","custom-renderer","inativeelementview"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}