dotnet/maui · error · NotSupportedException
Header cells do not support context actions
Error message
Header cells do not support context actions
What it means
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.
Source
Thrown at src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ListViewRenderer.cs:1215
if (height == -1)
height = _defaultSectionHeight;
return height;
}
return 0;
}
public override UIView GetViewForHeader(UITableView tableView, nint section)
{
if (!_list.TryGetTarget(out var list))
return null;
if (!list.IsGroupingEnabled)
return null;
var cell = list.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;
cell.TableView = tableView;
cell.ReusableCell = null;
var handler = cell.ToHandler(cell.FindMauiContext());
var renderer = (handler as CellRenderer) ?? (handler.PlatformView as CellRenderer);
header.SetTableViewCell(renderer.PlatformView);
return header;
}
public override void HeaderViewDisplayingEnded(UITableView tableView, UIView headerView, nint section)
{
if (!_list.TryGetTarget(out var list) || !list.IsGroupingEnabled)View on GitHub (pinned to f377ff1c5e)
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.
Example fix
// before — header template has context actions
<DataTemplate x:Key="HeaderTemplate">
<ViewCell>
<ViewCell.ContextActions>
<MenuItem Text="Edit" />
</ViewCell.ContextActions>
<Label Text="Group" />
</ViewCell>
</DataTemplate>
// after
<DataTemplate x:Key="HeaderTemplate">
<ViewCell>
<Label Text="Group" />
</ViewCell>
</DataTemplate> Defensive patterns
Strategy: validation
Validate before calling
// Ensure the header template has no ContextActions
// Use a dedicated header template without context actions
<DataTemplate x:Key="Header"><ViewCell><Label Text="{Binding Key}"/></ViewCell></DataTemplate> Type guard
static bool HeaderSupportsContextActions(ViewCell header) =>
header.ContextActions.Count == 0; Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
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/9e9d75e129276568.
Report an issue: GitHub.