1

I have a ListBox that 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?

H.B.
  • 166,899
  • 29
  • 327
  • 400
Geoff
  • 1,634
  • 16
  • 25
  • Looks like WFP 4.5 will get virtualization support for grouping: http://msdn.microsoft.com/en-us/library/bb613588(v=vs.110).aspx#grouped_virtualization – Geoff Sep 27 '11 at 12:25

1 Answers1

0

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

Community
  • 1
  • 1
Samich
  • 29,157
  • 6
  • 68
  • 77