lucasg/Dependencies · error · InvalidOperationException
FilterTextBindingPath is not set.
Error message
FilterTextBindingPath is not set.
What it means
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.
Source
Thrown at DependenciesGui/FilterControl/FilterControl.cs:258
#region Private Functions/Methods
private void ApplyFilterOnTarget()
{
if (TargetControl == null || TargetControl.Items.SourceCollection == null)
return;
ICollectionView collectionView = CollectionViewSource.GetDefaultView(TargetControl.Items.SourceCollection);
if (collectionView == null)
{
throw new InvalidOperationException("The TargetConrol should use ICollectionView as ItemSource.");
}
if (string.IsNullOrEmpty(this.FilterTextBindingPath))
{
throw new InvalidOperationException("FilterTextBindingPath is not set.");
}
collectionView.Filter = (m => (GetDataValue<string>(m, this.FilterTextBindingPath).IndexOf(this.FilterText, StringComparison.InvariantCultureIgnoreCase) > -1));
}
private void ClearFilterOnTarget()
{
if (TargetControl == null || TargetControl.Items.SourceCollection == null)
return;
ICollectionView collectionView = CollectionViewSource.GetDefaultView(TargetControl.Items.SourceCollection);
if (collectionView == null)
{
throw new InvalidOperationException("The TargetControl should use ICollectionView as ItemSource.");
}
View on GitHub (pinned to 1997a40000)
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.
Example fix
<!-- before -->
<filter:FilterControl TargetControl="{Binding ElementName=MyList}" />
<!-- after -->
<filter:FilterControl TargetControl="{Binding ElementName=MyList}"
FilterTextBindingPath="DisplayName" /> Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(filterControl.FilterTextBindingPath))
{
// do not raise the filter event; warn the developer at design time
return;
} Try / catch
try { filterControl.RaiseFilterEvent(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("FilterTextBindingPath"))
{ /* binding path missing - set it in XAML */ } Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- The TargetConrol should use ICollectionView as ItemSource.
- The TargetControl should use ICollectionView as ItemSource.
- Can only convert to string.
- Can only convert an instance of enum.
- {0:s} file could not be found !
AI-assisted analysis of lucasg/Dependencies@1997a40000 (2026-08-13).
Data as JSON: /api/errors/d4b6a16f63034d6c.
Report an issue: GitHub.