TreeView & HierarchicalDataTemplate  
Author Message
Raghavendra RAV





PostPosted: Windows Presentation Foundation (WPF), TreeView & HierarchicalDataTemplate Top

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




Visual Studio 200825  
 
 
lee d





PostPosted: Windows Presentation Foundation (WPF), TreeView & HierarchicalDataTemplate Top

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



 
 
Raghavendra RAV





PostPosted: Windows Presentation Foundation (WPF), TreeView & HierarchicalDataTemplate Top

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



 
 
lee d





PostPosted: Windows Presentation Foundation (WPF), TreeView & HierarchicalDataTemplate Top

yes, you have to walk up the tree nodes

 
 
footballism





PostPosted: Windows Presentation Foundation (WPF), TreeView & HierarchicalDataTemplate Top

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