dotnet/wpf · error · NotSupportedException
SR.BindingListCannotCustomFilter
Error message
SR.BindingListCannotCustomFilter
What it means
BindingListCollectionView.CustomFilter setter throws NotSupportedException when CanCustomFilter is false, i.e. the underlying IBindingList does not support filtering (its SupportsFiltering property is false). Custom filtering is delegated to the underlying BindingList, so if that list cannot filter, the view cannot either.
Solutions
- Back the view with a collection whose IBindingList.SupportsFiltering is true (e.g. DataTable, or a BindingList implementation that implements filtering).
- Check CanCustomFilter before setting CustomFilter and fall back to a CollectionView filter (CollectionView.Filter) where supported.
- Use ListCollectionView (over IList with filtering) or implement ICollectionView filtering at a different layer.
Example fix
// before
view.CustomFilter = "Amount > 100"; // throws if !CanCustomFilter
// after
if (view.CanCustomFilter)
view.CustomFilter = "Amount > 100";
else if (view.Filter == null)
view.Filter = o => ((MyItem)o).Amount > 100; Defensive patterns
Strategy: validation
Validate before calling
if (view is BindingListCollectionView blcv && !blcv.CanCustomFilter)
throw new SkipFilterException(); // skip CustomFilter assignment Type guard
bool SupportsCustomFilter(ICollectionView v) => v is BindingListCollectionView blcv && blcv.CanCustomFilter;
Try / catch
try { view.CustomFilter = filter; }
catch (NotSupportedException) { /* fall back to CollectionView.Filter */ } Prevention
- Check CanCustomFilter before setting CustomFilter
- Ensure source implements IBindingList with SupportsFiltering=true
- Have a CollectionView.Filter fallback for unsupported sources
When it happens
Trigger: Assigning CustomFilter on a BindingListCollectionView whose source collection's IBindingList.SupportsFiltering returns false (e.g. plain List<T> wrapped views or BindingList<T> implementations that do not enable filtering).
Common situations: Binding a DataGrid/ItemsControl to a BindingList<T> or DataTable-less custom collection that lacks filtering support, then attempting view-level CustomFilter; WPF apps ported from DataTable (which supports filtering) to custom collections.
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.MemberNotAllowedDuringAddOrEdit…
- SR.Format(SR.UnexpectedCollectionChangeAction, e.Action)
- SR.Format(SR.UnexpectedCollectionChangeAction, e.Action)
- SR.RangeActionsNotSupported
- By default, ToolTip property does not support ToolTip…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/b179ba658670e6c7.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs:304
}
/// <summary>
/// Gets or sets the filter to be used to exclude items from the collection of items returned by the data source .
/// </summary>
/// <remarks>
/// Before assigning, test if this CollectionView supports custom filtering
/// <seealso cref="CanCustomFilter"/>.
/// The actual syntax depends on the implementer of IBindingListView. ADO's DataView is
/// a common example, see System.Data.DataView.RowFilter for its supported
/// filter expression syntax.
/// </remarks>
public string CustomFilter
{
get { return _customFilter; }
set
{
if (!CanCustomFilter)
throw new NotSupportedException(SR.BindingListCannotCustomFilter);
if (IsAddingNew || IsEditingItem)
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedDuringAddOrEdit, "CustomFilter"));
if (AllowsCrossThreadChanges)
VerifyAccess();
_customFilter = value;
RefreshOrDefer();
}
}
/// <summary>
/// Test if this CollectionView supports custom filtering before assigning
/// a filter string to <seealso cref="CustomFilter"/>.
/// </summary>
public bool CanCustomFilter
{
getView on GitHub (pinned to 81131a70a4)