dotnet/wpf · error · InvalidOperationException
SR.Format(SR.CannotChangeLiveShaping, "IsLiveFiltering"…
Error message
SR.Format(SR.CannotChangeLiveShaping, "IsLiveFiltering", "CanChangeLiveFiltering")
What it means
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.
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.
Example fix
// before
((BindingListCollectionView)CollectionViewSource.GetDefaultView(dataTable)).IsLiveFiltering = true;
// after
if (CollectionViewSource.GetDefaultView(dataTable) is ListCollectionView lcv && lcv.CanChangeLiveFiltering)
lcv.IsLiveFiltering = true; Defensive patterns
Strategy: validation
Validate before calling
if (view is BindingListCollectionView)
throw new NotSupportedException("IsLiveFiltering cannot be set on BindingListCollectionView"); Type guard
bool canSetLiveFiltering(CollectionView v) => v is ListCollectionView lcv && lcv.CanChangeLiveFiltering;
Try / catch
try { view.IsLiveFiltering = true; }
catch (InvalidOperationException) { /* property is read-only on this view */ } Prevention
- Check CanChangeLiveFiltering before setting IsLiveFiltering
- Use ListCollectionView for toggleable live filtering
- Treat IsLive* on BindingListCollectionView as get-only
When it happens
Trigger: Assigning any value to IsLiveFiltering on a BindingListCollectionView (e.g. ((BindingListCollectionView)CollectionViewSource.GetDefaultView(dataTable)).IsLiveFiltering = false;). The throw occurs regardless of the assigned value.
Common situations: Code or XAML that toggles live filtering on the default view of a DataTable/DataView-backed ItemsSource, usually copied from ListCollectionView examples.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SR.Format(SR.CannotChangeLiveShaping, "IsLiveSorting"…
- SR.BindingExpressionIsDetached
- SR.ChangeSealedBinding
- SR.Format(SR.BindingConflict, SourceProperties.ElementName…
- SR.Format(SR.RequiresExplicitCulture, TargetProperty.Name)
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/3b3e10b4df14a1bf.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs:1134
/// Calling the setter when CanChangeLiveSorting is false will throw an
/// InvalidOperationException.
///</summary
public bool? IsLiveSorting
{
get { return IsDataView ? (bool?)true : (bool?)null; }
set { throw new InvalidOperationException(SR.Format(SR.CannotChangeLiveShaping, "IsLiveSorting", "CanChangeLiveSorting")); }
}
///<summary>
/// Gets or sets a value that indicates whether live filtering is enabled.
/// The value may be null if the view does not know whether live filtering is enabled.
/// Calling the setter when CanChangeLiveFiltering is false will throw an
/// InvalidOperationException.
///</summary>
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)View on GitHub (pinned to 81131a70a4)