{"record":{"id":"d4b6a16f63034d6c","repo":"lucasg/Dependencies","slug":"filtertextbindingpath-is-not-set","errorCode":null,"errorMessage":"FilterTextBindingPath is not set.","messagePattern":"FilterTextBindingPath is not set\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"DependenciesGui/FilterControl/FilterControl.cs","lineNumber":258,"sourceCode":"\n        #region Private Functions/Methods\n\n        private void ApplyFilterOnTarget()\n        {\n            if (TargetControl == null || TargetControl.Items.SourceCollection == null)\n                return;\n\n            ICollectionView collectionView = CollectionViewSource.GetDefaultView(TargetControl.Items.SourceCollection);\n\n            if (collectionView == null)\n            {\n                throw new InvalidOperationException(\"The TargetConrol should use ICollectionView as ItemSource.\");\n            }\n\n\n            if (string.IsNullOrEmpty(this.FilterTextBindingPath))\n            {\n                throw new InvalidOperationException(\"FilterTextBindingPath is not set.\");\n            }\n\n            collectionView.Filter = (m => (GetDataValue<string>(m, this.FilterTextBindingPath).IndexOf(this.FilterText, StringComparison.InvariantCultureIgnoreCase) > -1));\n\n        }\n\n        private void ClearFilterOnTarget()\n        {\n            if (TargetControl == null || TargetControl.Items.SourceCollection == null)\n                return;\n\n            ICollectionView collectionView = CollectionViewSource.GetDefaultView(TargetControl.Items.SourceCollection);\n\n            if (collectionView == null)\n            {\n                throw new InvalidOperationException(\"The TargetControl should use ICollectionView as ItemSource.\");\n            }            \n","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/lucasg/Dependencies/blob/1997a40000b77bd3326cbc33672a7b9f78bb23f3/DependenciesGui/FilterControl/FilterControl.cs#L240-L276","documentation":"InvalidOperationException thrown by FilterControl.ApplyFilterOnTarget when the FilterTextBindingPath dependency property is null or empty. The filter reads each item's display value via GetDataValue<string>(item, FilterTextBindingPath) using reflection/TypeDescriptor, so it must know which property to match against the typed FilterText.","triggerScenarios":"ApplyFilterOnTarget is invoked (text typed, Enter pressed with FilterOnEnter, or RaiseFilterEvent with no applied external handler) on a FilterControl whose FilterTextBindingPath was never set in XAML or code (it defaults to string.Empty).","commonSituations":"A developer drops FilterControl into a view but omits the FilterTextBindingPath attribute; the property name was renamed so the binding path is stale/empty; programmatic use without setting the property.","solutions":["Set FilterTextBindingPath in XAML to the item property you want to filter on (e.g. \"Name\", \"DisplayName\").","If using code-behind, assign filterControl.FilterTextBindingPath before any filter can fire.","Ensure the path names a real public property on the item type, otherwise GetDataValue throws its own InvalidOperationException.","Guard ApplyFilterOnTarget to no-op when FilterTextBindingPath is empty rather than throwing."],"exampleFix":"<!-- before -->\n<filter:FilterControl TargetControl=\"{Binding ElementName=MyList}\" />\n\n<!-- after -->\n<filter:FilterControl TargetControl=\"{Binding ElementName=MyList}\"\n                      FilterTextBindingPath=\"DisplayName\" />","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(filterControl.FilterTextBindingPath))\n{\n    // do not raise the filter event; warn the developer at design time\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { filterControl.RaiseFilterEvent(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"FilterTextBindingPath\"))\n{ /* binding path missing - set it in XAML */ }","preventionTips":["Set FilterTextBindingPath in the same XAML element that sets TargetControl.","Ensure the path names a real public property on the item type.","Add a design-time check/assert that FilterTextBindingPath is non-empty."],"tags":["wpf","filtercontrol","binding","configuration","invalidoperation"],"backgroundTag":null,"analyzedSha":"1997a40000b77bd3326cbc33672a7b9f78bb23f3","analyzedAt":"2026-08-13T18:14:41.696Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}