I can also paraphrase the question and ask how I can get a TreeViewItem out of a Model object in TreeView.Items?
I follow this tutorial and instead of TreeViewItems in the TreeView.Items collection I have objects of that model class.
However, I need to focus certain TreeView elements based on some other event. If TreeView.Items contained TreeViewItems I’d easily found a needed one and used its Focus() method. But since I’m using binding now I don’t know how to do that.
Of course, I can populate a TreeView programmatically by adding TreeViewItems objects, however I tried to avoid it and follow a more WPF-way of doing things with binding.
1 Answer