Can a TreeListViewItem span multiple columns while others not ?

Editors for WPF Forum

Posted 8 months ago by Daniel Constantin
Version: 19.1.0684
Avatar

For some items in the TreeListView I am trying to make them span all the columns. (Like using a TreeListBoxItem Style as the TreeListView -> ItemContainerStyle).

If I try to change the Template inside the TreeListViewItem it will break everything.

Comments (4)

Answer - Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

While the TreeListView doesn't support column spanning, you can override the item's template to not be column-based and to span all columns.  We effectively do that with our PropertyGrid control, which is based on TreeListView.  In that control, we define two columns, Name and Value.  For "category" rows, we use a different item template that will span the columns.

To do this, we set the ItemContainerStyleSelector property with a custom StyleSelector that picks either the normal Style (could probably return null to use the default) or a special Style for the special items with a custom template.

The trick in the template is having the content indent properly.  The container's TreeListViewItem.IndentAmount property gives the indent amount.

I hope that helps get you started.  I made a note that it might be nice to add a sample for this kind of scenario too.


Actipro Software Support

Posted 8 months ago by Daniel Constantin
Avatar

Hi,

Thanks for the quick response. That was what I was looking for. It worked when you return null for the default style. When not returning null(returning a style based on TreeListViewItem), I had some problems when scrolling up/down.. Seemed like some items lost the style associated (I saw the name of the view model instead) and after some other scrolling have the style good. Even tried with

VirtualizingStackPanel.IsVirtualizing="True"

Anyway for me is working returning null for default.

Thanks,

Daniel

Answer - Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

That's odd.  Any time we've see issues with WPF virtualization not updating styles/templates properly when scrolling, changing the default VirtualizingStackPanel.VirtualizationMode from "Recycling" to "Standard" seemed to fix the issue.  There is a note about that in the "Grids / Troubleshooting" topic in the documentation that comes with the product.  Maybe give that a try in the one scenario to see if it helps.


Actipro Software Support

Posted 7 months ago by Daniel Constantin
Avatar

Hi!

Thanks for the respose!

It worked with the VirtualizingStackPanel.VirtualizationMode = "Standard" or with the VirtualizingStackPanel.IsVirtualizing = false but the second option is not that good. I still want virtualization as I do not know how many items I need to display there.

Kind regards,
Daniel

The latest build of this product (v2020.1.1) was released 15 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.