I’ve been having issues with the TreeView
in WPF. This control makes it very hard to access the TreeViewItem
s it’s showing.
On several occasions I have worked around the need to access a TreeViewItem
, for example I’ve accepted the fact that I’m not supposed to access a node’s parent via TreeView (and am supposed to instead keep track of the parent myself). I’ve been doing this for two reasons: first, it’s obviously extremely hard to get at the TreeViewItem
s, and secondly, I’ve been told that it’s hard because I’m not supposed to need them if I do things right.
However, this time I really see no way around this.
Basically, all I want is, given one of my viewmodel instances, scroll the tree view to it. This is trivial if I could just get the corresponding TreeViewItem
.
Am I doing things wrong again by trying to get at the TreeViewItem
, or would that be the right approach?