绑定数据后遍历WPF treeView的所有节点 [英] Exapned all the nodes of WPF treeView after databinding
本文介绍了绑定数据后遍历WPF treeView的所有节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将WPF树视图绑定到对象后,如何扩展WPF树视图的所有节点.我在下面使用了代码
How we can expend all the nodes of WPF treeview once i have bound it to object. I have used code below
for (int i = 0; i < TreeViewLocal.Items.Count;i++)
{
TreeViewItem t2 = (TreeViewItem)TreeViewLocal.ItemContainerGenerator.ContainerFromItem(TreeViewLocal.Items[i]);
t2.IsExpanded = true;
}
但正如您所看到的,它将消耗顶级节点.对此高度赞赏的
But as you can see it will expends top level nodes.Any help on this highly appreciated
推荐答案
^ ]肯定会为您提供帮助.
This[^] will surely help you out.
尝试为您添加到TreeView的每个TreeViewItem手动将IsExpanded属性设置为IsTrue.
Try setting manually the IsExpanded property to IsTrue for every TreeViewItem you add to your TreeView.
这篇关于绑定数据后遍历WPF treeView的所有节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文