dotnet/maui · error · NotSupportedException
Header cells do not support context actions
Error message
Header cells do not support context actions
What it means
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.
Source
Thrown at src/Compatibility/Core/src/iOS/Renderers/ListViewRenderer.cs:1143
var cell = TemplatedItemsView.TemplatedItems[(int)section];
nfloat height = (float)cell.RenderHeight;
if (height == -1)
height = _defaultSectionHeight;
return height;
}
return 0;
}
public override UIView GetViewForHeader(UITableView tableView, nint section)
{
if (!List.IsGroupingEnabled)
return null;
var cell = TemplatedItemsView.TemplatedItems[(int)section];
if (cell.HasContextActions)
throw new NotSupportedException("Header cells do not support context actions");
const string reuseIdentifier = "HeaderWrapper";
var header = (HeaderWrapperView)tableView.DequeueReusableHeaderFooterView(reuseIdentifier) ?? new HeaderWrapperView(reuseIdentifier);
header.Cell = cell;
var renderer = (CellRenderer)Microsoft.Maui.Controls.Internals.Registrar.Registered.GetHandlerForObject<IRegisterable>(cell);
header.SetTableViewCell(renderer.GetCell(cell, null, tableView));
return header;
}
public override void HeaderViewDisplayingEnded(UITableView tableView, UIView headerView, nint section)
{
if (!List.IsGroupingEnabled)
return;
if (headerView is HeaderWrapperView wrapper)
{View on GitHub (pinned to f377ff1c5e)
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.
Example fix
<ListView IsGroupingEnabled="true" GroupHeaderTemplate="{StaticResource HeaderTpl}">
<!-- before: header template with context actions -->
<DataTemplate x:Key="HeaderTpl">
<TextCell Text="{Binding Title}">
<TextCell.ContextActions>
<MenuItem Text="Edit" />
</TextCell.ContextActions>
</TextCell>
</DataTemplate>
<!-- after: header template WITHOUT context actions -->
<DataTemplate x:Key="HeaderTpl">
<TextCell Text="{Binding Title}" />
</DataTemplate> Defensive patterns
Strategy: validation
Validate before calling
// In XAML/data-template design: ensure GroupHeaderTemplate cells have no ContextActions
// Programmatically check before binding:
foreach (var action in headerCell.ContextActions)
headerCell.ContextActions.Remove(action); // strip if present Prevention
- Keep a separate, context-action-free Cell template for group headers.
- Review templates before enabling IsGroupingEnabled.
When it happens
Trigger: Binding a ListView with IsGroupingEnabled=true where the GroupHeaderTemplate's Cell defines <Cell.ContextActions> entries.
Common situations: 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.
Related errors
- Header cells do not support context actions
- Implement INativeElementView on cell renderer: {ContentCell.
- No UIViewController found to present.
- group
- Implement INativeElementView on cell renderer: {ContentCell.
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/193850a115e28685.
Report an issue: GitHub.