1

It appears that TextSearch only searches the children of the selected TreeviewItem by default. I would like it to behave like Windows Explorer in that if no child matches then it should check siblings for matches.

For example, if I select the TreeViewItem with the header "B" and type "C" on the keyboard then I would like the TreeViewItem with the header of C to be selected:

<TreeView IsTextSearchEnabled="True">
<TreeViewItem IsTextSearchEnabled="True" Header="A"/>
<TreeViewItem IsTextSearchEnabled="True" Header="B">
    <TreeViewItem IsTextSearchEnabled="True" Header="D"/>
    <TreeViewItem IsTextSearchEnabled="True" Header="E"/>
    <TreeViewItem IsTextSearchEnabled="True" Header="F"/>
</TreeViewItem>
    <TreeViewItem IsTextSearchEnabled="True" Header="C"/>
 </TreeView>

Any ideas?

EDIT: I would like to continue using the in-built TextSearch functionality if possible.

MoonBoots89
  • 355
  • 2
  • 16
  • Seems like this is a common problem. For reference: http://stackoverflow.com/questions/11530643/treeview-search – gcarvelli Nov 20 '14 at 14:13
  • @killermonkey50 Thanks for the response but the link that you've posted relates to a user attempting a custom search through a TreeView in VB whilst my question relates to the in-built TextSearch functionality in WPF. I'll edit my question to specify that directly. – MoonBoots89 Nov 20 '14 at 14:17
  • the behavior in Windows Explorer treeview is different, user can type any letter ***at any time*** to move the selected item to the first matched item. While for the behavior you want (with `IsTextSearchEnabled`), matching item works only ***once***, after some matched item getting selected, typing some other letter won't match any item. BTW, changing the behavior of some built-in property like this seems to be impossible, just create your own custom attached property. – King King Nov 20 '14 at 14:27

0 Answers0