开发者

Enabling UI virtualization on the WPFToolkit Accordion

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开发者_C百科 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 UI virtualization. Is there any way to get the accordion to use UI virtualization? If not, is there any way I can improve the performance of the accordion so it will load the first level items more quickly?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜