I have a ListBox
t开发者_JAVA百科hat can contain hundreds of items. I've added the following attributes to the listbox and performance is great, even if I group / ungroup (using x as ListCollectionView
)
<ListBox ItemsSource="{Binding x}" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"/>
However, if I set the ListBox.GroupStyle
to anything, even the most simple thing possible, it takes a few seconds to switch from grouped -> ungrouped.
<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ItemsPresenter/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListBox.GroupStyle>
I think the reason for this is that WPF is throwing away the cache of containers (enabled by recycling mode in the VirtualizingStackPanel
) when I switch to ungrouped and is having to rebuild them from scratch.
Is there a way to improve the performance here? Can anyone suggest something I could try or perhaps a resource I could check out?
Check this post, maybe it will be helpful
WPF: Data Virtualization
Also I found similar question on stackoverflow: WPF ListView Virtualization Grouping
and another one (even with answer) WPF Data virtualizing ListView
精彩评论