user979901
user979901

Reputation: 51

How to get the Current expanded treeviewitem in WPF

I am not able to get , only the current item which is expanded . When I am trying to get the expanded item , i am getting all the expanded items from the treeview, but I don't want that , I need to get the clicked expanded item.

Upvotes: 1

Views: 2227

Answers (2)

Vinit Sankhe
Vinit Sankhe

Reputation: 19885

Please use

 e.Handled=true; 

in your treeViewItem.Expanded event handler. That way it will only fire for the actual item expanded and not bubble route to the parent tree view items.

Upvotes: 2

Emond
Emond

Reputation: 50672

You'll need to respond to the AfterExpand event.

By restricting to the click you are shutting out keyboard users.

EDIT

Sorry, that's WinForms. Here is the WPF solution:

<TreeView TreeViewItem.Expanded="TreeViewItem_Expanded" />

Upvotes: 2

Related Questions