dotnet/wpf · error · ArgumentNullException

(nameof(value)) ArgumentNullException

Error message

(nameof(value)) ArgumentNullException

What it means

The IsLiveSorting setter throws ArgumentNullException when assigned null. The property is typed bool? but null is explicitly rejected because the view needs an explicit true/false to decide whether to rebuild its live-sorting array.

Solutions

  1. Assign an explicit boolean: view.IsLiveSorting = true or false, never null.
  2. Coalesce at the call site: view.IsLiveSorting = settingsValue ?? false.
  3. Fix the bound source so it never yields null (use a non-nullable bool or a converter).

Example fix

// before
view.IsLiveSorting = config.LiveSorting; // null when unset

// after
view.IsLiveSorting = config.LiveSorting ?? false;
Defensive patterns

Strategy: validation

Validate before calling

if (value is bool b) view.IsLiveSorting = b; // never assign null

Type guard

bool IsValidLiveFlag(bool? v) => v != null;

Try / catch

try { view.IsLiveSorting = value; }
catch (ArgumentNullException)
{ view.IsLiveSorting = false; /* default */ }

Prevention

When it happens

Trigger: Assigning null to ListCollectionView.IsLiveSorting, e.g. from a binding that produces null, a settings value defaulting to null, or casting an object 'false' boxed value incorrectly.

Common situations: Data-binding IsLiveSorting to a nullable source; copying settings from config where the value was never set; reflection-based property copying that writes null.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/0816ca8cf6718910. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/ListCollectionView.cs:1392

        /// Gets a value that indicates whether this view supports turning live grouping on or off.
        ///</summary>
        public bool CanChangeLiveGrouping
        { get { return true; } }


        ///<summary>
        /// Gets or sets a value that indicates whether live sorting is enabled.
        /// The value may be null if the view does not know whether live sorting is enabled.
        /// Calling the setter when CanChangeLiveSorting is false will throw an
        /// InvalidOperationException.
        ///</summary
        public bool? IsLiveSorting
        {
            get { return _isLiveSorting; }
            set
            {
                if (value == null)
                    throw new ArgumentNullException(nameof(value));

                if (value != _isLiveSorting)
                {
                    _isLiveSorting = value;
                    RebuildLocalArray();

                    OnPropertyChanged(nameof(IsLiveSorting));
                }
            }
        }

        ///<summary>
        /// Gets or sets a value that indicates whether live filtering is enabled.
        /// The value may be null if the view does not know whether live filtering is enabled.
        /// Calling the setter when CanChangeLiveFiltering is false will throw an
        /// InvalidOperationException.
        ///</summary>
        public bool? IsLiveFiltering

View on GitHub (pinned to 81131a70a4)