{"record":{"id":"0816ca8cf6718910","repo":"dotnet/wpf","slug":"nameof-value-argumentnullexception","errorCode":null,"errorMessage":"(nameof(value)) ArgumentNullException","messagePattern":"\\(nameof\\(value\\)\\) ArgumentNullException","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/ListCollectionView.cs","lineNumber":1392,"sourceCode":"        /// Gets a value that indicates whether this view supports turning live grouping on or off.\n        ///</summary>\n        public bool CanChangeLiveGrouping\n        { get { return true; } }\n\n\n        ///<summary>\n        /// Gets or sets a value that indicates whether live sorting is enabled.\n        /// The value may be null if the view does not know whether live sorting is enabled.\n        /// Calling the setter when CanChangeLiveSorting is false will throw an\n        /// InvalidOperationException.\n        ///</summary\n        public bool? IsLiveSorting\n        {\n            get { return _isLiveSorting; }\n            set\n            {\n                if (value == null)\n                    throw new ArgumentNullException(nameof(value));\n\n                if (value != _isLiveSorting)\n                {\n                    _isLiveSorting = value;\n                    RebuildLocalArray();\n\n                    OnPropertyChanged(nameof(IsLiveSorting));\n                }\n            }\n        }\n\n        ///<summary>\n        /// Gets or sets a value that indicates whether live filtering is enabled.\n        /// The value may be null if the view does not know whether live filtering is enabled.\n        /// Calling the setter when CanChangeLiveFiltering is false will throw an\n        /// InvalidOperationException.\n        ///</summary>\n        public bool? IsLiveFiltering","sourceCodeStart":1374,"sourceCodeEnd":1410,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/ListCollectionView.cs#L1374-L1410","documentation":"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.","triggerScenarios":"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.","commonSituations":"Data-binding IsLiveSorting to a nullable source; copying settings from config where the value was never set; reflection-based property copying that writes null.","solutions":["Assign an explicit boolean: view.IsLiveSorting = true or false, never null.","Coalesce at the call site: view.IsLiveSorting = settingsValue ?? false.","Fix the bound source so it never yields null (use a non-nullable bool or a converter)."],"exampleFix":"// before\nview.IsLiveSorting = config.LiveSorting; // null when unset\n\n// after\nview.IsLiveSorting = config.LiveSorting ?? false;","handlingStrategy":"validation","validationCode":"if (value is bool b) view.IsLiveSorting = b; // never assign null","typeGuard":"bool IsValidLiveFlag(bool? v) => v != null;","tryCatchPattern":"try { view.IsLiveSorting = value; }\ncatch (ArgumentNullException)\n{ view.IsLiveSorting = false; /* default */ }","preventionTips":["Coalesce nullable sources with ?? false before assignment.","Type live-shaping settings as non-nullable bool.","Add null-to-bool converters on bindings feeding these properties."],"tags":["wpf","collectionview","null-argument","live-sorting"],"backgroundTag":"null-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}