views:

59

answers:

2

I am working on a (WPF + C#) application. I have to implement search functionality. It will allow to search all the occurrences of a particular string on the specific part of Window. What can be the best way to do this?

+2  A: 

Viky,

I hope I got you properly. You can take a look on what Kent Boogaart has: Search and Highlight Text in an Arbitrary Visual Tree:

alt text

Anvaka
@Anvaka: thanks for the reply its really helpful, but my window can contain other controls as well. like TextBox, ComboBox, i need to search Text in them also. Any suggestions?
viky
@Viky, as long as it's in the visual tree it should work (TextBoxes should work). As for the ComboBox... it's little trickier, because items in the drop down list are in popup's visual tree. In that case you would probably have to customize Kent's algorithm to check against "known" exceptions.
Anvaka
A: 

Hi,

You should try using ICollectionView for filtering. Here is an example.

decyclone