MahApps/MahApps.Metro · warning · NotSupportedException
Unsupported NotifyCollectionChangedAction
Error message
Unsupported NotifyCollectionChangedAction
What it means
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.
Source
Thrown at src/MahApps.Metro/Controls/MultiSelectionComboBox/MultiSelectionComboBox.cs:1348
{
this.PART_PopupListBox?.Items?.Remove(item);
}
}
break;
case NotifyCollectionChangedAction.Replace:
case NotifyCollectionChangedAction.Move:
case NotifyCollectionChangedAction.Reset:
this.PART_PopupListBox?.Items.Clear();
foreach (var item in this.Items)
{
this.PART_PopupListBox?.Items?.Add(item);
}
break;
default:
throw new NotSupportedException("Unsupported NotifyCollectionChangedAction");
}
}
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
// For now we only want to update our position if the height changed. Else we will get a flickering in SharedGridColumns
if (this.IsDropDownOpen && sizeInfo.HeightChanged)
{
this.BeginInvoke(multiSelectionComboBox =>
{
if (multiSelectionComboBox.PART_Popup is not null)
{
multiSelectionComboBox.PART_Popup.HorizontalOffset++;
multiSelectionComboBox.PART_Popup.HorizontalOffset--;
}
});View on GitHub (pinned to 72099e310b)
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.
Defensive patterns
Strategy: validation
Validate before calling
void OnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (!Enum.IsDefined(typeof(NotifyCollectionChangedAction), e.Action))
throw new ArgumentOutOfRangeException(nameof(e.Action));
// proceed
} Type guard
static bool IsStandardAction(NotifyCollectionChangedAction a) =>
a == NotifyCollectionChangedAction.Add
|| a == NotifyCollectionChangedAction.Remove
|| a == NotifyCollectionChangedAction.Replace
|| a == NotifyCollectionChangedAction.Move
|| a == NotifyCollectionChangedAction.Reset; Prevention
- Use ObservableCollection<T> for ItemsSource.
- Custom INotifyCollectionChanged sources should only raise the five standard actions.
- Adapt non-standard collections into an ObservableCollection before binding.
When it happens
Trigger: 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.
Common situations: Custom observable collection or test fixture firing a non-standard action. Not a typical production scenario.
Related errors
- Unknown SelectionMode
- Template part "{templatePart}" in template for "{target.GetT
- The provided dialog is already visible in the specified wind
- The provided dialog is not visible in the specified window.
- Dialog isn't visible to close
AI-assisted analysis of MahApps/MahApps.Metro@72099e310b (2026-08-13).
Data as JSON: /api/errors/3d424c2351aaaeef.
Report an issue: GitHub.