TreeView & HierarchicalDataTemplate

Hi,

I am using HierarchicalDataTemplate to bind my TreeView to list a set of directories. In our applicatoin, we have a favorites menu, from which user can navigate directly to a particular node in the tree.

I got the logic to get the active item. But I couldn't set it to the SelectedItem or SelectedValue of the TreeView as they are readonly properties. Is there a way to hack this or this is not possible in WPF with HierarchicalDataTemplate.

Please help me, this is blocking me to go further.

Thanks,
--------------------------------
Raghavendra RAV




Answer this question

TreeView & HierarchicalDataTemplate

  • Lejing

    yes, you have to walk up the tree nodes

  • ScooterBrown

    Hi,

    It worked. Actually I have to set the IsExpanded property to true to all of the parent nodes.

    That really solved my purpose. Thanks a ton.

    Regards,

    Raghu



  • giggsyny

    After successfully expand the node and select it, I believe you also wanna bring it into the view, you can do so by using TreeViewItem.BringIntoView().

    Sheva


  • nmahesh567

    Did you try setting the IsSelected=true on the item you want to be selected and then you can set the node(s) parent property IsExpanded=true



  • TreeView & HierarchicalDataTemplate