This is basically implementing search/find in a WPF window or User control. Let's say you have a WPF window with dynamic readonly text some on textblock, some in a listbox, some in treeview, some in textblocks etc.
The user should be able to type in a search term in a textbox on the top and be able to see it highlighted wherever and in whichever control the text appears in the window. And no, this page has nothing to do with FlowDocuments and such, so can't use out of the box FlowDocumentReader.
Call it 'control text search' and highlight the search term like Google chrome browser does for a webpage.
The following SO threads might be helpful, but not sure if I can achieve the above (I am trying to put something together)
There there is this article, which is also helpful but works with Documents and not controls
Alright I seem to have found a link that seems like what I was after.
Search and Highlight Text in an Arbitrary Visual Tree
I am going to go through this, will come back and update if it's the complete solution to the problem above
Update 1: Okay, this really works, the above link has code that actually solves this problem, great work there Kent !!! - It highlights all search text with yellow all at once, but one thing that is missing is the navigation highlighting, like next->next. I am planning to work on that and then I can post my updates here, so that it helps others.
Update 2: Alright there is another catch with this solution. The highlighting rectangles are drawn on the screen co-ordinates. So if you have long list of items, and you scroll, the highlighted rectangles still stick to the screen co-ords, as opposed to the textblocks themselves.
So now my teammate and I are going to be working on a different solution. Will keep this thread posted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With