dotnet/wpf · error · NotSupportedException
(no message) NotSupportedException
Error message
(no message) NotSupportedException
What it means
ListCollectionView.GroupBySelector is settable only when the view can group (CanGroup). If grouping is not enabled/supported, assigning GroupBySelector throws a bare NotSupportedException before the add/edit-state check is even reached.
Solutions
- Ensure grouping is supported and enabled: add a PropertyGroupDescription to view.GroupDescriptions so CanGroup is true
- Only set GroupBySelector when view.CanGroup is true
- Check whether the underlying IList supports grouping requirements; if not, switch to a collection/view that does
Example fix
// before
view.GroupBySelector = SelectGroup; // NotSupportedException if !CanGroup
// after
if (!view.CanGroup)
view.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
view.GroupBySelector = SelectGroup; Defensive patterns
Strategy: validation
Validate before calling
if (!view.CanGroup)
{
view.GroupDescriptions.Add(new PropertyGroupDescription("Category")); // enable grouping
}
view.GroupBySelector = SelectGroup; Try / catch
try { view.GroupBySelector = selector; }
catch (NotSupportedException)
{
// grouping not available for this view; fall back to no grouping
} Prevention
- Verify CanGroup before touching GroupBySelector
- Set up GroupDescriptions before assigning a group selector
- Test grouping features against the concrete underlying collection type
When it happens
Trigger: Assigning GroupBySelector on a ListCollectionView whose CanGroup is false — typically when SortDescriptions/GroupDescriptions support is unavailable for the underlying list or grouping was never enabled.
Common situations: Attaching grouping logic to a view over a collection that does not support grouping; enabling GroupBySelector in code without first configuring GroupDescriptions; binding a grouping UI control to a non-groupable view.
Related errors
- SR.Format(SR.MemberNotAllowedDuringAddOrEdit, "Grouping")
- SR.Format(SR.CannotGroupView, view)
- SR.Format(SR.MemberNotAllowedDuringAddOrEdit, "CustomSort")
- SR.Format(SR.MemberNotAllowedDuringAddOrEdit, "Filter")
- SR.Format(SR.MemberNotAllowedDuringAddOrEdit, "Grouping")
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/ec9ae1711258469e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/ListCollectionView.cs:481
SetSortDescriptions(null);
RefreshOrDefer();
}
}
/// <summary>
/// A delegate to select the group description as a function of the
/// parent group and its level.
/// </summary>
[DefaultValue(null)]
public virtual GroupDescriptionSelectorCallback GroupBySelector
{
get { return _group.GroupBySelector; }
set
{
if (!CanGroup)
throw new NotSupportedException();
if (IsAddingNew || IsEditingItem)
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedDuringAddOrEdit, "Grouping"));
_group.GroupBySelector = value;
RefreshOrDefer();
}
}
/// <summary>
/// Return the estimated number of records (or -1, meaning "don't know").
/// </summary>
public override int Count
{
get
{
VerifyRefreshNotDeferred();
View on GitHub (pinned to 81131a70a4)