tags:

views:

2296

answers:

2
+3  A: 

Unfortunately, as I'm sure you have discovered, is that you can set the treeViewInstance.SelectedItem property as it's read-only.

From memory, each TreeViewItem has a IsSelected property that you can set. You try to listen for expand/collapse on the items and maybe set this property. Without trying this myself I don't know if it is a) a good solution b) if it would even works.

To get the TreeViewItem that is the container for the item in collection use

treeViewInstance.ItemContainerGenerator.ContainerFromItem(yourDataItem) as TreeViewItem;

Another idea (the way I would do it) is to use a ListBox/ListView and fake the hierarchical view. The create a view model controller and item, wrap your data, and manage this all yourself. If you want more information, please leave a comment and I will dig up a few examples to help.

HTH,

Dennis

Dennis Roche
A: 

Hi, There are two apporches choose what ever you like. i) explore ItemTemplageSelector, not sure but may be possible to do work with it.

Other wise on tree expand event or mouse capture event get the Current Root node and then select its first child with index like rootNode.child[0]... set this is as Selected True or Isfocused and perfom operation that is intended on its click you you will make user feel like it is selected.

Aizaz