TreeListBox/TreeListView + HierarchicalDataTemplate - Supported?

Grids for WPF Forum

Posted 5 years ago by eric
Version: 18.1.0674


im trying to port some old WPF TreeView code to use actipro TreeListBox but i cannot seem to manage to display anything else than the root.

It seems like Actipro TreeList do not support HierarchicalDataTemplate. Is this true?

I tried looking at the examples but they don't help me. They either define the data directly in the XAML or using some kind of TreeListAdapter.

Please note that my list structure is not using predefined items type like in the example.

Each nodes can be of a given type and the Child collection may have different names and type. 

The HierarchicalDataTemplate/DataTemplate was working great with the WPF TreeView but the visual and selection behavior is not that great.

Am i missing something here?

Comments (2)

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

Hi Eric,

That is correct, the HierarchicalDataTemplate will not work with TreeListBox.

TreeListBox is set up so that it is completely separated from the data model and doesn't know anything about it.  The item adapter is what is a bridge between the TreeListBox control and the actual data model, and communicates between them.  The nice thing about this is that it can be very fast (compared to data bindings as with things like HierarchicalDataTemplate) and allows your data model to have no UI dependencies.

Anyhow, you should make an item adapter that has a GetChildren method override that examines a given data item and returns its child collection.  You can determine what is children of what in the code for that method. 

The "Grids / Tree Control Features / Getting Started" topic in the documentation talks about all this in detail and walks through it.  I'd recommend reading that as it will get you going quickly. 

You don't need your data items to inherit our sample TreeNodeModel but having the kinds of properties on the data items that it has will help with supporting various functionalities provided by the control.  Once you're all set, your tree should perform very well and behave as an advanced tree control like the one in the VS Solution Explorer.

Actipro Software Support

Posted 5 years ago by eric

Thank you for your prompt reply.

I started to modify my code to follow the adapter approach. So far so good.

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

Add Comment

Please log in to a validated account to post comments.