I use the StackPanel to compose multiple controls vertically (e.g. Title, sub titles, listbox, separator, listbox, etc.).
StackPanel is a child of ScrollViewer to ensure that its contents always scroll.
One of the controls in the StackPanel is the ListBox.
The ItemsSource property is data tied to a huge collection, and the complex DataTemplate is used to implement each item.
Unfortunately, I get very low performance (high processor / memory) with it.
I tried
- setting the ListBox ItemsPanel to VirtualizationStackPanel and
- redefinition of its ControlTemplate only in ItemPresenter (remove ListBox ScrollViewer).
But there was no difference in appearances. I assume that the StackPanel gives its inner children infinite height during measurement?
When I replaced ScrollViewer and StackPanel with other panels / layouts (e.g. Grid, DockPanel), and the performance improved significantly, which makes me think that the bottleneck as well as the solution are in virtualization.
Is there a way to improve processor / memory performance in this view?

[Update 1]
Original project example: http://s000.tinyupload.com/index.php?file_id=29810707815310047536
[Update 2]
I tried restyling / templating TreeView / TreeViewItems to give the following example. It still takes a long time to start / same, using high memory. But after loading, the scroll feels much more responsive than the original sample.
I wonder if there is another way to further improve startup / memory usage time?
Restyled TreeView Project: http://s000.tinyupload.com/index.php?file_id=00117351345725628185
[Update 2]
Pushpraj works like a charm
- Original:
- Commissioning: 35 seconds,
- Memory: 393 MB
- Scrolling: Slow
- TreeView:
- Commissioning: 18 s,
- Memory 377 MB,
- Scrolling: fast
- Pushpraj solution:
- Run: <1s,
- Memory: 20 MB,
- Scrolling: fast