在 WPFToolkit Accordion 上启用 UI 虚拟化

发布于 2024-09-29 20:32:00 字数 1315 浏览 6 评论 0原文

我正在使用 WPFToolkit Accordion 控件,其中手风琴中的项目定义为 TreeView。

对于上下文,这里是 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">

最初,我仅使用 TreeView(没有 WPFToolkit Accordian)实现了此功能,并在一秒钟内加载了 40,000 个项目。

当我在根级别使用手风琴实现该结构时,单击扩展器时的加载时间长达 7 秒以上。这太长了。

我对应用程序进行了分析,发现第一级中的 500 个项目正在被递归测量,这导致加载时间增加。 Accordion 控件似乎未使用 UI 虚拟化。有什么办法让手风琴使用UI虚拟化吗?如果没有,有什么方法可以提高手风琴的性能,以便它更快地加载第一级项目?

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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文