本文介绍了如何以编程方式选择在一个WPF树视图中的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这怎么可能以编程方式选择在WPF 的TreeView
的项目?该的ItemsControl
模式似乎prevent吧。
How is it possible to programmatically select an item in a WPF TreeView
? The ItemsControl
model seems to prevent it.
推荐答案
这是一些奇怪的原因,你必须使用ContainerFromItem拿到容器中,然后调用选择方法,一个真正的痛苦。有一个关于如何做到这一点的博客条目here.
It's a real pain for some strange reason, you have to use ContainerFromItem to get the container, then invoke the select method. There's a blog entry on how to do it here.
这篇关于如何以编程方式选择在一个WPF树视图中的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!