PropertyGrid - Empty categories remain visible after DataFilter excludes all properties

Grids for WPF Forum

The latest build of this product (v25.1.2) was released 1 month ago, which was before this thread was created.
Posted 4 days ago by Scott Currie
Version: 25.1.2
Platform: .NET 9
Environment: Windows 11 (64-bit)
Avatar

We're using Actipro PropertyGrid (v25.1.x) with WPF and need to hide categories that become empty after filtering.

Setup:
<grids:PropertyGrid IsFilterActive="True">
<grids:PropertyGrid.DataFilter>
<apshared:DataFilterGroup>
<grids:PropertyModelStringFilter Source="Name" Operation="NotEquals" Value="ConnectionString" />
<grids:PropertyModelStringFilter Source="Name" Operation="NotEquals" Value="FilePath" />
<!-- etc. - excluding specific properties by name -->
</apshared:DataFilterGroup>
</grids:PropertyGrid.DataFilter>
</grids:PropertyGrid>

Problem:
When DataFilter excludes all properties in a category (e.g., "Required"), the category header remains visible as an empty expander. We expected categories with no visible children to be hidden
automatically.

What we tried:
1. Code-behind approach: Listening to ItemContainerGenerator.StatusChanged, iterating over ICategoryModel items, checking children against the filter, and setting container.Visibility =
Collapsed on empty categories - no effect
2. XAML ItemContainerStyle with triggers - broke category display

Question:
Is there a built-in way to automatically hide empty categories when filtering, or what is the recommended approach in v25.x? The forum mentions "Filters QuickStart" should hide parent
categories, but this doesn't appear to work with PropertyModelStringFilter.

Comments (3)

Posted 4 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

I opened the "PropertyGridFiltersBuiltin" QuickStart, which uses a group of PropertyModelStringFilter and PropertyModelBooleanFilter together as an example.  When I change the filter to exclude items, I do see the containing categories all drop out when empty, which is expected behavior.

As a further test, I simplified that sample down by using a PropertyModelStringFilter alone, and saw it working as expected that way as well.

Perhaps take a look at that sample and see if you can detect if you are doing anything differently.  Use it as a starting point and see if you can reproduce the issue or determine what is causing it.  Please let us know what you find, or if you require further assistance.


Actipro Software Support

Posted 1 days ago by Scott Currie
Avatar

I identified the root cause. Your QuickStart sample works correctly because it uses the default Contains operation. The issue is specific to NotEquals filters.

The Problem:
When using PropertyModelStringFilter with Operation="NotEquals" and Source="Name" to exclude properties (e.g., Value="ConnectionString"), categories are inadvertently matched by the filter because:

1. Categories (ICategoryModel) also have a Name property
2. The category name (e.g., "Required") does not equal "ConnectionString"
3. The NotEquals condition evaluates to TRUE
4. The filter returns Included instead of IncludedByDescendants

Suggested Fix:
When PropertyModelStringFilter encounters an item that is not IPropertyModel, it should return IncludedByDescendants regardless of whether the filter condition happens to match - since the filter is semantically designed for property filtering, not category filtering.

Posted 19 hours ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

Thanks and I agree with your assessment.  I believe the reason it was opened up to more than just IPropertyModel was so that it could match ICategoryEditorModel objects as well, since those contain properties.  We have updated the PropertyModelStringFilter.Filter logic to only look at IPropertyModel in general, along with ICategoryEditorModel but only for Category matching there.  Otherwise, it will return FallbackFilterResult, which is IncludedByDescendants by default.  Category models will always return FallbackFilterResult.

The related change in the Release History for the next version 25.1.3 is:

Updated PropertyModelStringFilter logic to only include category models via descendants and only include category editor models on Category match.

If you'd like to test a preview build with the update, please write our support address and mention this thread.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.