0
votes

I'm using a TreeView bound to a nested collection of mine. It works fine, but when I expand a node using the little arrow, I would like to get the reference to the object bound to this node. I tried using the "sender" and the EventArgs, but I get the TreeViewItem, and not my object.

What can I try ?

1
Let us look at your relevant code pleaseLeo Chapiro

1 Answers

2
votes

You can use the DataContext of the TreeViewItem.

MyObject myObject = (treeViewItem.DataContext as MyObject);