{"record":{"id":"3fdda88dca72f3cf","repo":"dotnet/wpf","slug":"sr-format-sr-cannotchangeliveshaping-islivesorting","errorCode":null,"errorMessage":"SR.Format(SR.CannotChangeLiveShaping, \"IsLiveSorting\", \"CanChangeLiveSorting\")","messagePattern":"SR\\.Format\\(SR\\.CannotChangeLiveShaping, \"IsLiveSorting\", \"CanChangeLiveSorting\"\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs","lineNumber":1122,"sourceCode":"        { get { return false; } }\n\n        ///<summary>\n        /// 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 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","sourceCodeStart":1104,"sourceCodeEnd":1140,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs#L1104-L1140","documentation":"BindingListCollectionView exposes IsLiveSorting only as a read-only indicator (true when the underlying collection is an IBindingListView/DataView, null otherwise). Its setter unconditionally throws InvalidOperationException because BindingListCollectionView cannot change live sorting; live shaping can only be toggled on views where CanChangeLiveSorting is true (e.g. ListCollectionView).","triggerScenarios":"Setting the IsLiveSorting property on a BindingListCollectionView instance (e.g. ((BindingListCollectionView)CollectionViewSource.GetDefaultView(dataTable)).IsLiveSorting = true;). The throw is unconditional — it does not depend on the value assigned.","commonSituations":"XAML or code that sets IsLiveSorting on the default view of an ADO.NET DataTable/DataView or any IBindingListView-backed source, often code copied from examples written for ListCollectionView or ObservableCollection views.","solutions":["Do not set IsLiveSorting on BindingListCollectionView; read it to check whether live sorting is active.","If live shaping toggling is required, use a ListCollectionView (e.g. over an ObservableCollection) where CanChangeLiveSorting is true.","Wrap the set in a check: only assign when the view is a ListCollectionView and CanChangeLiveSorting is true.","For DataView-backed sources, control live sorting through the underlying DataView / binding list instead of the view."],"exampleFix":"// before\n((BindingListCollectionView)CollectionViewSource.GetDefaultView(dataTable)).IsLiveSorting = true;\n\n// after\nvar view = CollectionViewSource.GetDefaultView(dataTable); // read-only indicator\nbool liveSortingActive = (view as BindingListCollectionView)?.IsLiveSorting == true;","handlingStrategy":"validation","validationCode":"if (view is BindingListCollectionView)\n    throw new NotSupportedException(\"IsLiveSorting cannot be set on BindingListCollectionView\");","typeGuard":"bool canSetLiveSorting(CollectionView v) => v is ListCollectionView lcv && lcv.CanChangeLiveSorting;","tryCatchPattern":"try { view.IsLiveSorting = true; }\ncatch (InvalidOperationException) { /* view is read-only for live shaping */ }","preventionTips":["Only toggle live shaping on ListCollectionView","Check CanChangeLiveSorting before assigning any IsLive* property","Never set IsLive* on views created from DataTable/DataView sources"],"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"}