{"record":{"id":"3d424c2351aaaeef","repo":"MahApps/MahApps.Metro","slug":"unsupported-notifycollectionchangedaction","errorCode":null,"errorMessage":"Unsupported NotifyCollectionChangedAction","messagePattern":"Unsupported NotifyCollectionChangedAction","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"warning","filePath":"src/MahApps.Metro/Controls/MultiSelectionComboBox/MultiSelectionComboBox.cs","lineNumber":1348,"sourceCode":"                        {\n                            this.PART_PopupListBox?.Items?.Remove(item);\n                        }\n                    }\n\n                    break;\n\n                case NotifyCollectionChangedAction.Replace:\n                case NotifyCollectionChangedAction.Move:\n                case NotifyCollectionChangedAction.Reset:\n                    this.PART_PopupListBox?.Items.Clear();\n                    foreach (var item in this.Items)\n                    {\n                        this.PART_PopupListBox?.Items?.Add(item);\n                    }\n\n                    break;\n                default:\n                    throw new NotSupportedException(\"Unsupported NotifyCollectionChangedAction\");\n            }\n        }\n\n        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)\n        {\n            base.OnRenderSizeChanged(sizeInfo);\n\n            // For now we only want to update our position if the height changed. Else we will get a flickering in SharedGridColumns\n            if (this.IsDropDownOpen && sizeInfo.HeightChanged)\n            {\n                this.BeginInvoke(multiSelectionComboBox =>\n                    {\n                        if (multiSelectionComboBox.PART_Popup is not null)\n                        {\n                            multiSelectionComboBox.PART_Popup.HorizontalOffset++;\n                            multiSelectionComboBox.PART_Popup.HorizontalOffset--;\n                        }\n                    });","sourceCodeStart":1330,"sourceCodeEnd":1366,"githubUrl":"https://github.com/MahApps/MahApps.Metro/blob/72099e310bac2d12ac98fd7560b69679252519f5/src/MahApps.Metro/Controls/MultiSelectionComboBox/MultiSelectionComboBox.cs#L1330-L1366","documentation":"Thrown in the ItemsSource collection-changed handler of MultiSelectionComboBox when a NotifyCollectionChangedAction value is not Add, Remove, Replace, Move, or Reset. The switch handles all five standard enum members; the default is unreachable with standard ObservableCollection but guards against future enum extensions or custom INotifyCollectionChanged implementations.","triggerScenarios":"A custom collection implementing INotifyCollectionChanged raises CollectionChanged with an action value outside the standard five members (only possible via an untyped/reflective raise). Standard ObservableCollection will never produce this.","commonSituations":"Custom observable collection or test fixture firing a non-standard action. Not a typical production scenario.","solutions":["Use ObservableCollection<T> or a collection that only raises standard Add/Remove/Replace/Move/Reset actions.","If implementing a custom INotifyCollectionChanged source, restrict to the five documented actions.","Wrap non-standard collections in an ObservableCollection adapter before binding."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"void OnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)\n{\n    if (!Enum.IsDefined(typeof(NotifyCollectionChangedAction), e.Action))\n        throw new ArgumentOutOfRangeException(nameof(e.Action));\n    // proceed\n}","typeGuard":"static bool IsStandardAction(NotifyCollectionChangedAction a) =>\n    a == NotifyCollectionChangedAction.Add\n    || a == NotifyCollectionChangedAction.Remove\n    || a == NotifyCollectionChangedAction.Replace\n    || a == NotifyCollectionChangedAction.Move\n    || a == NotifyCollectionChangedAction.Reset;","tryCatchPattern":null,"preventionTips":["Use ObservableCollection<T> for ItemsSource.","Custom INotifyCollectionChanged sources should only raise the five standard actions.","Adapt non-standard collections into an ObservableCollection before binding."],"tags":["wpf","mahapps","combobox","collection-changed","defensive-guard"],"backgroundTag":null,"analyzedSha":"72099e310bac2d12ac98fd7560b69679252519f5","analyzedAt":"2026-08-13T20:19:34.419Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}