Concatenating 2 ObservableCollections in TreeListBoxItemAdapter.GetChildren

Grids for WPF Forum

Posted 6 years ago by John Dunn
Version: 18.1.0672
Avatar

I have an object that has 2 properties, each of which is an ObservableCollection. The first is of type T, the second is of type S, which derives from T. I'd like to display these in a TreeListBox with collection 1 coming first and then collection 2.

I tried returning a CompositeCollection containing 2 CollectionContainers, each assigned to the appropriate collection. This wouldn't be ideal since each collection would be displayed in it's own sub tree but I couldn't even get that to work. The CollectionConatiners show up in the TreeListBox but GetChildren is never called passing the CollectionContainer in and the object so no children are displayed.

Is there a way I can make this work or will I need to implement my own custom object that implemented INotifyCollectionChanged?

Comments (4)

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

Hi John,

It might be that our built-in collection handling logic doesn't recognize CompositeCollection.  Could you put together a new simple sample project that shows what you're trying to do and maybe a quick mockup of how it should look and send that to our support address so we can look into it?  Be sure to remove any bin/obj folders from what you send and rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 6 years ago by John Dunn
Avatar

I've sent a project to the support address. Just to clarify - CompositeCollection might be one way to accomplish what I want - basically to have items from 2 different collections at the same level in the tree, but I'm totally open to other suggestions as well.

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

Hi John,

Thanks for the sample.  The problem was that CompositeCollection is an IEnumerable of CollectionContainer objects and not the actual data items.  Thus when we iterate it to look for data items, we are getting your CollectionContainer objects.  What we really need you to bind to as a source data item enumerable is this:

_AllView = ((ICollectionViewFactory)_All).CreateView();

If you cache that view result as a field alongside your _All field and return the view in your MyAdapter.GetChildren method, it will work since now our logic will look at the actual data items and not yoru CollectionContainer objects.


Actipro Software Support

Posted 6 years ago by John Dunn
Avatar

That works. Thanks!

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

Add Comment

Please log in to a validated account to post comments.