wpf - 需要一个带有虚拟化和按需加载的 WPF TreeView 搜索示例

标签 wpf search treeview lazy-loading virtualization

我需要在 WPF 中实现搜索功能 TreeView (基本上我需要记住上次用户选择)。我尝试了各种建议的方法,但没有任何效果如 virtualization在我的 TreeView 中启用和子节点仅在父节点展开时加载(延迟加载)。

任何人都知道将这三件事(虚拟化、按需加载和搜索)一起实现的示例吗?

最佳答案

看看this MSDN 论坛帖子,来自 MS 的 Bob 解释了实现此功能的问题。

the cause is the VirtualizingStackPanel try to generate a item for display, but it has a generator already in your project to generate the expanded items (in the OnTreeNodeExpanded event handler). It occurs conflict with two generators. VirtualizingStackPanel can generate the required item at run-time, it also generate them in BringIndexIntoView method. The code of the StartAt method is to check the generator, if it isn't null, throw the exception "Cannot call StartAt when content generation is in progress". So, the sample populates all items to the bound source in the InitializeComponent(), and let the BringIndexIntoView method to generates the container for the item.



该线程中还附有重现该问题的示例。

所以目前这种方法似乎没有解决方案:(

关于wpf - 需要一个带有虚拟化和按需加载的 WPF TreeView 搜索示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3715583/

相关文章:

javascript - 检查对象数组是否包含给定字符串

visual-studio-code - 在自定义 TreeView 中添加拖放支持

delphi - 如何在运行时在 TTreeView 的选定项旁边放置一个按钮?

c# - WPF 文本框文本更新

php - PHP吐出PHP Parse错误:语法错误,/home/cg/root/main.php中第38行出现意外的“类”(T_CLASS)

c# - WPF。双态元素

c++ - 动态 ArrayList 的线性和二进制搜索

C#、WPF、在 Treeview 中重用图像

wpf - 如何将一个 WPF 表单嵌入到另一个表单中?

c# - 自动化测试期间的 WPF 组件资源