Trying to get virtualization working in a complex TreeView. There are three node types: Map->Layers->Legend Groups. Complexity is added due to the fact that items in the last node (Legend Groups) are represented by a ListBox of legend classes.
The scenario I'm looking at involves expanding a Legend Group to reveal 5000 legend classes. It takes ~1 second to init the list data and ~30 seconds for WPF to bind the ListBox. This hangs the GUI for 30 seconds so obviously, we would like to virtualize the list to speed this up.
Any thoughts on how to make this work would be appreciated. More details...
TreeView has the following flags set:
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.ScrollUnit="Pixel"
Maps -> <HierarchicalDataTemplate DataType="{x:Type tocInternal:TOCMapViewModel}" ItemsSource="{Binding Children}"
Layers -> <HierarchicalDataTemplate DataType="{x:Type tocInternal:TOCLayerViewModel}" ItemsSource="{Binding Children}"
LegendGroups ->
<DataTemplate DataType="{x:Type toc:TOCLegendGroupViewModel}">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{Binding LegendGroup.Heading}"
Visibility="{Binding HasHeading, Converter={StaticResource VisibleIfTrue}}">
</TextBlock>
<ListBox ItemContainerStyle="{StaticResource LegendClassStyle}" ItemsSource="{Binding Children}"
VirtualizingStackPanel.IsVirtualizing="True" SelectionMode="Extended" BorderThickness="0"
VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.ScrollUnit="Pixel"
ScrollViewer.CanContentScroll="True" Background="{DynamicResource Esri_Gray100}"
ScrollViewer.IsDeferredScrollingEnabled="True">
<i:Interaction.Behaviors>
<frameworkBehaviors:PropagateMouseWheelBehavior/>
</i:Interaction.Behaviors>
</ListBox>
</DockPanel>
</DataTemplate>