bodong1987 / Avalonia.PropertyGrid

A property edit control in Avalonia like DevExpress's PropertyGridControl.
https://www.cnblogs.com/bodong
MIT License
187 stars 18 forks source link

[Bug] Empty categories are displayed #8

Closed Elscrux closed 1 year ago

Elscrux commented 1 year ago

Categories that have no members to display, for example when they are hidden by VisibilityPropertyCondition are still displayed in the categories list at the top. When there are lots of categories which not might be visible based on conditions it gets very messy.

Here, "Category A" shouldn't be displayed until one element of the category is displayed.

[ConditionTarget]
public bool Enable { get; set; }

[Category("Category A")]
[VisibilityPropertyCondition(nameof(Enable), true)]
public bool Test { get; set; }
bodong1987 commented 1 year ago

I personally think this behavior is reasonable, if the category is removed when the dynamic visibility changes, when the property is visible again, the previous category filter information is lost. Moreover, the quick filter tags are analyzed at one time when the object is first set, and will not be refreshed halfway, so you may encounter a situation where there is no editable attribute under a category.

Elscrux commented 1 year ago

If I understood you correctly the points you make are mainly about limitations in the implementation, you're not disregarding the behavior I propose directly, right? Without knowing specifics about the implementation, I think the first point you raise that the information about the filter is lost when a filtered category is toggled off and on again could be solved by detaching the displayed categories from the actual categories in data where the filter information would persist, no matter if you hide the category from the view or not. Your second point that the categories aren't refreshed of course might need some more work on it which I can't expect to be implemented just for this request. I may look into getting this feature implemented by myself in the future, would you be interested in a PR down the line?