{"record":{"id":"9e9d75e129276568","repo":"dotnet/maui","slug":"header-cells-do-not-support-context-actions-9e9d75","errorCode":null,"errorMessage":"Header cells do not support context actions","messagePattern":"Header cells do not support context actions","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ListViewRenderer.cs","lineNumber":1215,"sourceCode":"\t\t\t\t\tif (height == -1)\n\t\t\t\t\t\theight = _defaultSectionHeight;\n\n\t\t\t\t\treturn height;\n\t\t\t\t}\n\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tpublic override UIView GetViewForHeader(UITableView tableView, nint section)\n\t\t\t{\n\t\t\t\tif (!_list.TryGetTarget(out var list))\n\t\t\t\t\treturn null;\n\t\t\t\tif (!list.IsGroupingEnabled)\n\t\t\t\t\treturn null;\n\n\t\t\t\tvar cell = list.TemplatedItems[(int)section];\n\t\t\t\tif (cell.HasContextActions)\n\t\t\t\t\tthrow new NotSupportedException(\"Header cells do not support context actions\");\n\n\t\t\t\tconst string reuseIdentifier = \"HeaderWrapper\";\n\t\t\t\tvar header = (HeaderWrapperView)tableView.DequeueReusableHeaderFooterView(reuseIdentifier) ?? new HeaderWrapperView(reuseIdentifier);\n\t\t\t\theader.Cell = cell;\n\n\t\t\t\tcell.TableView = tableView;\n\t\t\t\tcell.ReusableCell = null;\n\n\t\t\t\tvar handler = cell.ToHandler(cell.FindMauiContext());\n\t\t\t\tvar renderer = (handler as CellRenderer) ?? (handler.PlatformView as CellRenderer);\n\t\t\t\theader.SetTableViewCell(renderer.PlatformView);\n\n\t\t\t\treturn header;\n\t\t\t}\n\n\t\t\tpublic override void HeaderViewDisplayingEnded(UITableView tableView, UIView headerView, nint section)\n\t\t\t{\n\t\t\t\tif (!_list.TryGetTarget(out var list) || !list.IsGroupingEnabled)","sourceCodeStart":1197,"sourceCodeEnd":1233,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ListViewRenderer.cs#L1197-L1233","documentation":"Thrown by the iOS ListViewRenderer's GetViewForHeader when the section header cell has ContextActions. iOS UITableView header views do not support context-action swipe menus, so attaching them is explicitly rejected.","triggerScenarios":"Setting ContextActions on the cell used as a group/section header when ListView.IsGroupingEnabled is true. Assigning the same cell template to both headers and items where the template carries context actions.","commonSituations":"Grouping a ListView and reusing an item DataTemplate (that has context actions) for group headers. Adding context actions to a GroupHeaderTemplate. Migrating a flat list with context actions into a grouped list without removing header actions.","solutions":["Remove ContextActions from the GroupHeaderTemplate / header cell.","Use a dedicated header template without context actions, distinct from the item template.","Move the desired actions into the header tap behavior or a separate UI affordance."],"exampleFix":"// before — header template has context actions\n<DataTemplate x:Key=\"HeaderTemplate\">\n  <ViewCell>\n    <ViewCell.ContextActions>\n      <MenuItem Text=\"Edit\" />\n    </ViewCell.ContextActions>\n    <Label Text=\"Group\" />\n  </ViewCell>\n</DataTemplate>\n\n// after\n<DataTemplate x:Key=\"HeaderTemplate\">\n  <ViewCell>\n    <Label Text=\"Group\" />\n  </ViewCell>\n</DataTemplate>","handlingStrategy":"validation","validationCode":"// Ensure the header template has no ContextActions\n// Use a dedicated header template without context actions\n<DataTemplate x:Key=\"Header\"><ViewCell><Label Text=\"{Binding Key}\"/></ViewCell></DataTemplate>","typeGuard":"static bool HeaderSupportsContextActions(ViewCell header) =>\n    header.ContextActions.Count == 0;","tryCatchPattern":null,"preventionTips":["Never add ContextActions to group/section header cells.","Use a separate header template distinct from the item template.","Surface header actions via a different UI affordance."],"tags":["maui","listview","ios","grouping","context-actions","header"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}