dotnet/wpf · error · ArgumentNullException

ArgumentNullException(nameof(value))

Error message

ArgumentNullException(nameof(value))

What it means

The IsLiveGrouping setter on BindingListCollectionView requires a non-null bool?; passing null throws ArgumentNullException(nameof(value)). Unlike IsLiveSorting/IsLiveFiltering, this property is actually settable, but only with true or false.

Solutions

  1. Assign true or false instead of null; use false to turn live grouping off.
  2. Ensure the bound source property is a non-null bool (bool rather than bool?) or provide a DefaultValue/converter.
  3. Add a null check or coalesce before assignment: view.IsLiveGrouping = flag ?? false;

Example fix

// before
view.IsLiveGrouping = someNullableBool;

// after
view.IsLiveGrouping = someNullableBool ?? false;
Defensive patterns

Strategy: validation

Validate before calling

if (flag == null) throw new ArgumentException("IsLiveGrouping requires true/false");
view.IsLiveGrouping = flag.Value;

Type guard

bool isValidLiveGroupingValue(bool? v) => v is true or false;

Try / catch

try { view.IsLiveGrouping = flag; }
catch (ArgumentNullException) { view.IsLiveGrouping = false; }

Prevention

When it happens

Trigger: Assigning null explicitly (e.g. view.IsLiveGrouping = null;) or binding a nullable bool that evaluates to null to IsLiveGrouping. Also occurs when data-binding supplies a null value through a converter or missing value.

Common situations: Two-way bindings to IsLiveGrouping where the source property is a nullable bool that is unset; code that clears live grouping by assigning null instead of false.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs:1149

        public bool? IsLiveFiltering
        {
            get { return IsDataView ? (bool?)true : (bool?)null; }
            set { throw new InvalidOperationException(SR.Format(SR.CannotChangeLiveShaping, "IsLiveFiltering", "CanChangeLiveFiltering")); }
        }

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


                if (value != _isLiveGrouping)
                {
                    _isLiveGrouping = value;
                    RefreshOrDefer();

                    OnPropertyChanged(nameof(IsLiveGrouping));
                }
            }
        }

        ///<summary>
        /// Gets a collection of strings describing the properties that
        /// trigger a live-sorting recalculation.
        /// The strings use the same format as SortDescription.PropertyName.
        ///</summary>
        ///<notes>

View on GitHub (pinned to 81131a70a4)