WPF TreeView ICollectionView 删除过滤器
我有一个深度不同的 WPF TreeView。我的应用程序还具有在树内部搜索的能力。这是通过使用 ICollectionView 接口的 Filter 属性来完成的。搜索和过滤一切正常,但问题出在我尝试删除过滤器时。
我有以下场景;我输入搜索条件,树视图被过滤并显示结果。现在,当我按下按钮清除过滤器时,过滤器被删除,但问题是它只显示我之前搜索的子节点,而不显示其他节点的子节点,这些节点也是不可扩展的不再了。
我的搜索函数递归地沿着树走下去,并测试每个节点是否有输入的搜索文本。
我是否必须应用 view.Filter = null;每个节点及其子节点的语句?
谢谢,
格兰特
I have a WPF TreeView which varies in depth. My application also has the ability to search inside the tree. This is accomplished by using the Filter property of the ICollectionView interface. Searching and filtering all works fine, but the problem lies when I try to remove the filter.
I have the following scenario; I enter search criteria and the treeview is filtered and the result is shown. Now when I press my button to clear the filter, the filter is removed but the problem is that it shows only the child nodes of what I previously searched for and does not show the child nodes of the other nodes, these nodes are also not expandable anymore.
My search function recursively walks down the tree and tests each node for the entered search text.
Do I have to apply the view.Filter = null; statement for each node and their childnodes?
Thanks,
Grant
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的!
每个层次结构级别都有自己的 ICollectionView,并且每个级别都使用自己的过滤。所以是的,您必须清除每个(父)节点上的过滤器(取决于您的具体实现)。
Yes!
Every hierarchy level has it's own ICollectionView and each uses it's own filtering. So yes, yu have to clear the filter on every (parent-)node (depending on your exact implementation).