Is there a way to conditionally collapse a category in the xamPropertyGrid at runtime?
Regards,
Arthur
Hello Arthur,
Thank you for your post.
I have created a short project in order to show you how you can achieve the functionality you are looking for. Basically in the sample application I created style for PropertyGridCategoryItemView in the resources of XamPropertyGrid and handled its Loaded event in EventSetter. In the event handler of Loaded event I got the Category I want by the DisplayName property of PropertyGridCategoryItemView. Then I get its ToggleButton from the visual tree by using GetDescendantFromType method of our Utilities class and set its IsChecked property to false in order to Collapse the category. Please take a look at the attached sample application and let me know if I am missing something from your scenario.
Please let me know if you require any further assistance in the matter I will be glad to help.
Your example works fine if the category is on screen. However, if it is out of view and then I scroll to that category, it is not collapsed. You can see this in your example by changing "Action" to "Misc". Is there another approach that will work for this?