{"record":{"id":"3b3e10b4df14a1bf","repo":"dotnet/wpf","slug":"sr-format-sr-cannotchangeliveshaping-islivefiltering","errorCode":null,"errorMessage":"SR.Format(SR.CannotChangeLiveShaping, \"IsLiveFiltering\", \"CanChangeLiveFiltering\")","messagePattern":"SR\\.Format\\(SR\\.CannotChangeLiveShaping, \"IsLiveFiltering\", \"CanChangeLiveFiltering\"\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs","lineNumber":1134,"sourceCode":"        /// Calling the setter when CanChangeLiveSorting is false will throw an\n        /// InvalidOperationException.\n        ///</summary\n        public bool? IsLiveSorting\n        {\n            get { return IsDataView ? (bool?)true : (bool?)null; }\n            set { throw new InvalidOperationException(SR.Format(SR.CannotChangeLiveShaping, \"IsLiveSorting\", \"CanChangeLiveSorting\")); }\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\n        {\n            get { return IsDataView ? (bool?)true : (bool?)null; }\n            set { throw new InvalidOperationException(SR.Format(SR.CannotChangeLiveShaping, \"IsLiveFiltering\", \"CanChangeLiveFiltering\")); }\n        }\n\n        ///<summary>\n        /// Gets or sets a value that indicates whether live grouping is enabled.\n        /// The value may be null if the view does not know whether live grouping is enabled.\n        /// Calling the setter when CanChangeLiveGrouping is false will throw an\n        /// InvalidOperationException.\n        ///</summary>\n        public bool? IsLiveGrouping\n        {\n            get { return _isLiveGrouping; }\n            set\n            {\n                if (value == null)\n                    throw new ArgumentNullException(nameof(value));\n\n\n                if (value != _isLiveGrouping)","sourceCodeStart":1116,"sourceCodeEnd":1152,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs#L1116-L1152","documentation":"BindingListCollectionView exposes IsLiveFiltering only as a read-only indicator (true when the source is an IBindingListView/DataView, null otherwise). Its setter unconditionally throws InvalidOperationException because this view type cannot change live filtering; only views where CanChangeLiveFiltering is true (e.g. ListCollectionView) support it.","triggerScenarios":"Assigning any value to IsLiveFiltering on a BindingListCollectionView (e.g. ((BindingListCollectionView)CollectionViewSource.GetDefaultView(dataTable)).IsLiveFiltering = false;). The throw occurs regardless of the assigned value.","commonSituations":"Code or XAML that toggles live filtering on the default view of a DataTable/DataView-backed ItemsSource, usually copied from ListCollectionView examples.","solutions":["Remove the setter call; use IsLiveFiltering only to query whether live filtering is enabled.","Use ListCollectionView over a changeable collection when live filtering must be toggled.","Guard the assignment with a type check on the view and CanChangeLiveFiltering.","Toggle filtering via the underlying DataView/IBindingListView instead."],"exampleFix":"// before\n((BindingListCollectionView)CollectionViewSource.GetDefaultView(dataTable)).IsLiveFiltering = true;\n\n// after\nif (CollectionViewSource.GetDefaultView(dataTable) is ListCollectionView lcv && lcv.CanChangeLiveFiltering)\n    lcv.IsLiveFiltering = true;","handlingStrategy":"validation","validationCode":"if (view is BindingListCollectionView)\n    throw new NotSupportedException(\"IsLiveFiltering cannot be set on BindingListCollectionView\");","typeGuard":"bool canSetLiveFiltering(CollectionView v) => v is ListCollectionView lcv && lcv.CanChangeLiveFiltering;","tryCatchPattern":"try { view.IsLiveFiltering = true; }\ncatch (InvalidOperationException) { /* property is read-only on this view */ }","preventionTips":["Check CanChangeLiveFiltering before setting IsLiveFiltering","Use ListCollectionView for toggleable live filtering","Treat IsLive* on BindingListCollectionView as get-only"],"tags":["wpf","data-binding","live-shaping","invalid-operation"],"backgroundTag":"unsupported-operation","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"}