在 WPFToolkit Accordion 上启用 UI 虚拟化
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论