{"record":{"id":"193850a115e28685","repo":"dotnet/maui","slug":"header-cells-do-not-support-context-actions","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/Compatibility/Core/src/iOS/Renderers/ListViewRenderer.cs","lineNumber":1143,"sourceCode":"\t\t\t\t\tvar cell = TemplatedItemsView.TemplatedItems[(int)section];\n\t\t\t\t\tnfloat height = (float)cell.RenderHeight;\n\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.IsGroupingEnabled)\n\t\t\t\t\treturn null;\n\n\t\t\t\tvar cell = TemplatedItemsView.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\tvar renderer = (CellRenderer)Microsoft.Maui.Controls.Internals.Registrar.Registered.GetHandlerForObject<IRegisterable>(cell);\n\t\t\t\theader.SetTableViewCell(renderer.GetCell(cell, null, tableView));\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.IsGroupingEnabled)\n\t\t\t\t\treturn;\n\n\t\t\t\tif (headerView is HeaderWrapperView wrapper)\n\t\t\t\t{","sourceCodeStart":1125,"sourceCodeEnd":1161,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Renderers/ListViewRenderer.cs#L1125-L1161","documentation":"When the ListView is grouped (IsGroupingEnabled), each group header is rendered via GetViewForHeader. MAUI does not support context actions (the long-press menu) on group header cells, so if the header Cell has ContextActions set, it throws NotSupportedException rather than silently ignoring or crashing UIKit.","triggerScenarios":"Binding a ListView with IsGroupingEnabled=true where the GroupHeaderTemplate's Cell defines <Cell.ContextActions> entries.","commonSituations":"Reusing a non-grouped cell template (which had context actions) as a group header template; designing grouped lists and adding swipe/long-press menus to headers by mistake.","solutions":["Remove all ContextActions from the Cell used in GroupHeaderTemplate; context actions are only valid on data cells.","If a menu is needed on a header, implement it manually with a custom renderer or a UIGestureRecognizer on a custom header view.","Split into two Cell templates: one (no context actions) for headers, one for items."],"exampleFix":"<ListView IsGroupingEnabled=\"true\" GroupHeaderTemplate=\"{StaticResource HeaderTpl}\">\n<!-- before: header template with context actions -->\n<DataTemplate x:Key=\"HeaderTpl\">\n  <TextCell Text=\"{Binding Title}\">\n    <TextCell.ContextActions>\n      <MenuItem Text=\"Edit\" />\n    </TextCell.ContextActions>\n  </TextCell>\n</DataTemplate>\n\n<!-- after: header template WITHOUT context actions -->\n<DataTemplate x:Key=\"HeaderTpl\">\n  <TextCell Text=\"{Binding Title}\" />\n</DataTemplate>","handlingStrategy":"validation","validationCode":"// In XAML/data-template design: ensure GroupHeaderTemplate cells have no ContextActions\n// Programmatically check before binding:\nforeach (var action in headerCell.ContextActions)\n    headerCell.ContextActions.Remove(action); // strip if present","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a separate, context-action-free Cell template for group headers.","Review templates before enabling IsGroupingEnabled."],"tags":["notsupportedexception","ios","listview","grouping","context-actions"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}