{"record":{"id":"b179ba658670e6c7","repo":"dotnet/wpf","slug":"sr-bindinglistcannotcustomfilter","errorCode":null,"errorMessage":"SR.BindingListCannotCustomFilter","messagePattern":"SR\\.BindingListCannotCustomFilter","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs","lineNumber":304,"sourceCode":"        }\n\n        /// <summary>\n        /// Gets or sets the filter to be used to exclude items from the collection of items returned by the data source .\n        /// </summary>\n        /// <remarks>\n        /// Before assigning, test if this CollectionView supports custom filtering\n        /// <seealso cref=\"CanCustomFilter\"/>.\n        /// The actual syntax depends on the implementer of IBindingListView. ADO's DataView is\n        /// a common example, see System.Data.DataView.RowFilter for its supported\n        /// filter expression syntax.\n        /// </remarks>\n        public string CustomFilter\n        {\n            get { return _customFilter; }\n            set\n            {\n                if (!CanCustomFilter)\n                    throw new NotSupportedException(SR.BindingListCannotCustomFilter);\n                if (IsAddingNew || IsEditingItem)\n                    throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedDuringAddOrEdit, \"CustomFilter\"));\n                if (AllowsCrossThreadChanges)\n                    VerifyAccess();\n\n                _customFilter = value;\n\n                RefreshOrDefer();\n            }\n        }\n\n        /// <summary>\n        /// Test if this CollectionView supports custom filtering before assigning\n        /// a filter string to <seealso cref=\"CustomFilter\"/>.\n        /// </summary>\n        public bool CanCustomFilter\n        {\n            get","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingListCollectionView.cs#L286-L322","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nview.CustomFilter = \"Amount > 100\"; // throws if !CanCustomFilter\n\n// after\nif (view.CanCustomFilter)\n    view.CustomFilter = \"Amount > 100\";\nelse if (view.Filter == null)\n    view.Filter = o => ((MyItem)o).Amount > 100;","handlingStrategy":"validation","validationCode":"if (view is BindingListCollectionView blcv && !blcv.CanCustomFilter)\n    throw new SkipFilterException(); // skip CustomFilter assignment","typeGuard":"bool SupportsCustomFilter(ICollectionView v) => v is BindingListCollectionView blcv && blcv.CanCustomFilter;","tryCatchPattern":"try { view.CustomFilter = filter; }\ncatch (NotSupportedException) { /* fall back to CollectionView.Filter */ }","preventionTips":["Check CanCustomFilter before setting CustomFilter","Ensure source implements IBindingList with SupportsFiltering=true","Have a CollectionView.Filter fallback for unsupported sources"],"tags":["wpf","collection-view","filtering","not-supported"],"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"}