{"record":{"id":"54fbf4de72a33788","repo":"dotnet/wpf","slug":"throw-new-invalidoperationexception-sr-format-sr-54fbf4","errorCode":null,"errorMessage":"throw new InvalidOperationException(SR.Format(SR.CannotChangeLiveShaping, \"IsLiveGrouping\", \"CanChangeLiveGrouping\"));","messagePattern":"throw new InvalidOperationException\\(SR\\.Format\\(SR\\.CannotChangeLiveShaping, \"IsLiveGrouping\", \"CanChangeLiveGrouping\"\\)\\);","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/CollectionViewProxy.cs","lineNumber":854,"sourceCode":"        /// 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        bool? ICollectionViewLiveShaping.IsLiveGrouping\n        {\n            get\n            {\n                ICollectionViewLiveShaping cvls = ProxiedView as ICollectionViewLiveShaping;\n                return cvls?.IsLiveGrouping;\n            }\n            set\n            {\n                ICollectionViewLiveShaping cvls = ProxiedView as ICollectionViewLiveShaping;\n                if (cvls != null)\n                    cvls.IsLiveGrouping = value;\n                else\n                    throw new InvalidOperationException(SR.Format(SR.CannotChangeLiveShaping, \"IsLiveGrouping\", \"CanChangeLiveGrouping\"));\n            }\n        }\n\n\n        ///<summary>\n        /// Gets a collection of strings describing the properties that\n        /// trigger a live-sorting recalculation.\n        /// The strings use the same format as SortDescription.PropertyName.\n        ///</summary>\n        ///<notes>\n        /// When this collection is empty, the view will use the PropertyName strings\n        /// from its SortDescriptions.\n        ///\n        /// This collection is useful when sorting is described code supplied\n        /// by the application  (e.g. ListCollectionView.CustomSort).\n        /// In this case the view does not know which properties the code examines;\n        /// the application should tell the view by adding the relevant properties\n        /// to the LiveSortingProperties collection.","sourceCodeStart":836,"sourceCodeEnd":872,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/CollectionViewProxy.cs#L836-L872","documentation":"CollectionViewProxy throws this when the IsLiveGrouping setter is called but the proxied view does not implement ICollectionViewLiveShaping (or does not report CanChangeLiveGrouping). WPF raises it to signal that live shaping cannot be changed on this view, so the property assignment fails immediately with an InvalidOperationException rather than silently doing nothing.","triggerScenarios":"Setting the IsLiveGrouping property on a CollectionViewProxy whose ProxiedView is not an ICollectionViewLiveShaping (e.g. a plain CollectionView or custom ICollectionView without live shaping support).","commonSituations":"Binding IsLiveGrouping in XAML or code on a view that does not support live grouping (e.g. a CompositeCollectionView-backed or custom view); applying live-shaping settings uniformly across heterogeneous collection views where some views lack the feature.","solutions":["Check CanChangeLiveGrouping (or cast the view to ICollectionViewLiveShaping) before setting IsLiveGrouping.","Only enable live grouping on views known to support it, e.g. ListCollectionView over a collection whose items implement ILiveShaping properties.","If the source collection must support live shaping, back it with a ListCollectionView instead of a proxy over a non-shaping view."],"exampleFix":"// before\nviewProxy.IsLiveGrouping = true;\n\n// after\nif (viewProxy is ICollectionViewLiveShaping cvls && cvls.CanChangeLiveGrouping)\n{\n    cvls.IsLiveGrouping = true;\n}","handlingStrategy":"validation","validationCode":"if (viewProxy is ICollectionViewLiveShaping cvls && cvls.CanChangeLiveGrouping)\n    viewProxy.IsLiveGrouping = value;","typeGuard":"bool supportsLiveShaping = view.ProxiedView is ICollectionViewLiveShaping;","tryCatchPattern":null,"preventionTips":["Always gate live-shaping properties on CanChangeLiveGrouping/CanChangeLiveSorting/CanChangeLiveFiltering.","Document which view types in your app support ICollectionViewLiveShaping.","Guard XAML bindings with a converter that returns false when the feature is unsupported."],"tags":["wpf","data-binding","collection-view","live-shaping"],"backgroundTag":"invalid-state-transition","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}