wpf treeview大数据 [英] wpf treeview big data

查看:238
本文介绍了wpf treeview大数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

wpf加载数据缓慢(约100,000)虚拟化技术。不兼容xp。求解expert.Each级别应为100,000。

wpf load data slow (about 100,000) a virtualization technology.Not compatible with xp. Solve expert.Each level should be 100,000.

推荐答案

是的,WPF树视图已知有点慢,所以不要将所有元素添加到treeview。



假设你正在使用视图模型,你可以为每个节点执行''Children''集合的延迟初始化。



类似于:

Yes, the WPF treeview is known to be a bit slow, so don''t add all the elements to the treeview.

Assuming you''re using a view model, you could perform lazy initialization of the ''Children'' collection for each node.

Something like:
ObservableCollection<node> children;
public ObservableCollection<node> Children
{
 get
 {
   if(children == null)
   {
     LoadChildren();
   }
   return children;
 }
}
</node></node>



其中LoadChildren();显然必须初始化并填充子集合。



您还需要为Node类声明一个HierarchicalDataTemplate:


where LoadChildren(); obviously must initialize and populate the children collection.

You will also need to declare a HierarchicalDataTemplate for the Node class:

<HierarchicalDataTemplate x:Key="NodeTemplate" ItemsSource="{Binding Children}">
  <StackPanel>
    <TextBlock Text="{Binding Path=Name}" />
  </StackPanel>
</HierarchicalDataTemplate>





虽然不是与WPF树视图相关的性能的最终修复,但它更好而不是最初使用所有项目填充树。您还可以通过在单独的线程中异步执行 LoadChildren(); 来扩展此方法。



Best问候

Espen Harlinn



While not a final fix for performance related to the WPF treeview, it''s better than initially populating the tree with all the items. You can also expand on this method by performing the LoadChildren(); asynchronously in a separate thread.

Best regards
Espen Harlinn


谢谢。上面的窗口Xp是不兼容加载数据的延迟。
Thank you.Is the window Xp above is not compatible delay to load data.


是没有相应的源代码,虽然我提到这个问题困扰了几天。
Is there no corresponding source code, though I refer to this problem has troubled days.


这篇关于wpf treeview大数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆