How to expand only the item added in a ObservableCollection

Grids for WPF Forum

Posted 6 years ago by David Garcia
Version: 18.1.0672
Avatar

Hi, 

We are using the Actipro Property Grid, and we have an ObservableCollection that we are changing dynamically, but after the action to add a new "item" to this collection ... all the properties that belong to this collection are:

- Expanded if the ArePropertiesAutoExpanded is true
- Collapsed if the ArePropertiesAutoExpanded is false.

We want to add/remove an item and after that we want to keep the collection as it was before the add/remove action. Which is the way to achieve this goal?

Thanks.

Comments (1)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi David,

This is a complex issue.  While we can detect single add/remove item from collection scenarios, and would likely be able to add/remove the affected items from the UI, the main problem are the parent collection property and the siblings of the item added/removed.  

For instance the parent collection property often shows a count of child items in its value.  This comes from a .NET property descriptor.  Likewise, the items generally show an index (e.g. "[1]") as their property name, which also comes from property descriptors.  As sibling items are added/removed, the existing property descriptors aren't refreshed by .NET.  New ones have to be retrieved from .NET for the properties, and that mainly requires a call to fully refresh the parent collection property.

This refresh process is what clears out all the child nodes and adds new ones, as if it were the first time being displayed.  That's why you see what you see, because the data factory's GetDataModels method is being called for the parent collection property and is effectively rebuilding the expandable nodes underneath it.

We've looked into this for a while and there isn't really any easy way to do a simple add/remove while also updating the parent/siblings appropriately, without a full refresh like that.  The downside of course is you do lose expansion states with the refresh.


Actipro Software Support

The latest build of this product (v24.1.3) was released 28 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.