views:

33

answers:

0

I am using the WPFToolkit Accordion control with the items in the accordion defined to be a TreeView.

For context, here is the relevant part of the XAML:

<ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="True">
    <layoutToolkit:Accordion DockPanel.Dock="Bottom"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                ItemsSource="{Binding FoodTypes}"
                SelectionMode="ZeroOrOne"
                VirtualizingStackPanel.IsVirtualizing="True"
                VirtualizingStackPanel.VirtualizationMode="Recycling">
        <layoutToolkit:Accordion.ContentTemplate>
            <DataTemplate>
                <TreeView Margin="0 0 0 0" BorderThickness="0" 
                          ItemsSource="{Binding ChildrenView}"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Stretch"
                          VirtualizingStackPanel.IsVirtualizing="True"
                          VirtualizingStackPanel.VirtualizationMode="Recycling">

Originally I implemented this with just a TreeView (no WPFToolkit Accordian) and the 40,000 items loaded in under a second.

When I implemented the structure with an accordion at the root level the load time when clicking the expander went up to over 7 seconds. This is too long.

I profiled the application and saw that 500 items in the first level were being measured recursively and that was causing load time to increase. It appears the Accordion control is not using the UI Virtualizing. Is there any way to get the accordion to use the UI Virtualizing? If not is there any way I can improve the performance of the accordion so it will load the first level items more quickly?