lepoco/wpfui · warning · ArgumentOutOfRangeException

Unsupported action: {e.Action}

Error message

Unsupported action: {e.Action}

What it means

Thrown by NavigationView's NavigationStackOnCollectionChanged default branch when a NotifyCollectionChangedAction value is not Add/Remove/Replace/Move/Reset. The full enum is covered, so this is a defensive exhaustive-switch guard: it can only fire if a future .NET release adds a new action value, or a custom collection raises a fabricated action. Under normal use it is unreachable.

Source

Thrown at src/Wpf.Ui/Controls/NavigationView/NavigationView.Base.cs:526

                _breadcrumbBarItems.Add(
                    new NavigationViewBreadcrumbItem((INavigationViewItem)e.NewItems![0]!)
                );
                break;
            case NotifyCollectionChangedAction.Remove:
                _breadcrumbBarItems.RemoveAt(e.OldStartingIndex);
                break;
            case NotifyCollectionChangedAction.Replace:
                _breadcrumbBarItems[0] = new NavigationViewBreadcrumbItem(
                    (INavigationViewItem)e.NewItems![0]!
                );
                break;
            case NotifyCollectionChangedAction.Move:
                break;
            case NotifyCollectionChangedAction.Reset:
                _breadcrumbBarItems.Clear();
                break;
            default:
                throw new ArgumentOutOfRangeException(nameof(e), e.Action, $"Unsupported action: {e.Action}");
        }

        UpdateBreadcrumbContents();
    }

    private void UpdateBreadcrumbContents()
    {
        foreach (var breadcrumbItem in _breadcrumbBarItems)
        {
            breadcrumbItem.UpdateFromSource();
        }
    }
}

View on GitHub (pinned to ffebacd610)

Solutions

  1. Use the built-in NavigationView navigation journal rather than mutating the stack with custom actions.
  2. If you supply a custom collection, only raise Add/Remove/Replace/Move/Reset.
  3. On .NET upgrade, check the INotifyCollectionChanged changelog for new actions and update accordingly.
  4. Treat hitting this throw as a sign of an unsupported collection mutation pattern, not a runtime bug to retry.
Defensive patterns

Strategy: try-catch

Try / catch

try { /* navigation stack mutation */ }
catch (ArgumentOutOfRangeException ex) when (ex.Message.Contains("Unsupported action"))
{
    Logger.Error($"Unsupported collection action raised: {ex.Message}");
}

Prevention

When it happens

Trigger: The NavigationStack observable collection raises a CollectionChanged with an action outside the known enum set (e.g. a future-added enum member, or a custom collection passing an invalid cast integer to NotifyCollectionChangedEventArgs).

Common situations: Upgrading to a future .NET where INotifyCollectionChanged gains a new action; a custom navigation stack implementation that misuses NotifyCollectionChangedEventArgs; a corrupted/edge-case Replace where NewItems is null causing an earlier NRE rather than this throw.

Related errors


AI-assisted analysis of lepoco/wpfui@ffebacd610 (2026-08-13). Data as JSON: /api/errors/aa1bbc4ddc7a6e0b. Report an issue: GitHub.