{"record":{"id":"ec9ae1711258469e","repo":"dotnet/wpf","slug":"no-message-notsupportedexception","errorCode":null,"errorMessage":"(no message) NotSupportedException","messagePattern":"\\(no message\\) NotSupportedException","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/ListCollectionView.cs","lineNumber":481,"sourceCode":"\n                SetSortDescriptions(null);\n\n                RefreshOrDefer();\n            }\n        }\n\n        /// <summary>\n        /// A delegate to select the group description as a function of the\n        /// parent group and its level.\n        /// </summary>\n        [DefaultValue(null)]\n        public virtual GroupDescriptionSelectorCallback GroupBySelector\n        {\n            get { return _group.GroupBySelector; }\n            set\n            {\n                if (!CanGroup)\n                    throw new NotSupportedException();\n                if (IsAddingNew || IsEditingItem)\n                    throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedDuringAddOrEdit, \"Grouping\"));\n\n                _group.GroupBySelector = value;\n\n                RefreshOrDefer();\n            }\n        }\n\n        /// <summary>\n        /// Return the estimated number of records (or -1, meaning \"don't know\").\n        /// </summary>\n        public override int Count\n        {\n            get\n            {\n                VerifyRefreshNotDeferred();\n","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/ListCollectionView.cs#L463-L499","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nview.GroupBySelector = SelectGroup; // NotSupportedException if !CanGroup\n// after\nif (!view.CanGroup)\n    view.GroupDescriptions.Add(new PropertyGroupDescription(\"Category\"));\nview.GroupBySelector = SelectGroup;","handlingStrategy":"validation","validationCode":"if (!view.CanGroup)\n{\n    view.GroupDescriptions.Add(new PropertyGroupDescription(\"Category\")); // enable grouping\n}\nview.GroupBySelector = SelectGroup;","typeGuard":null,"tryCatchPattern":"try { view.GroupBySelector = selector; }\ncatch (NotSupportedException)\n{\n    // grouping not available for this view; fall back to no grouping\n}","preventionTips":["Verify CanGroup before touching GroupBySelector","Set up GroupDescriptions before assigning a group selector","Test grouping features against the concrete underlying collection type"],"tags":["wpf","data-binding","notsupportedexception","listcollectionview","grouping"],"backgroundTag":"operation-not-supported","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}