Click here to Skip to main content
15,887,262 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

I am writing code Highlight Searched Text with ListView in WPF.

The problem is that when I search a specific word, only match words in the screen visible are hightlighted but the other words in

listviewItems that should be highlighted which are located in the bottom of the listview are not highlighted.

After I run the program and I scroll down manually to the bottom in the list view and when I search the word, then it works well.

What I have tried:

To solve the problem, I added the code like below. Listview scrolls down and up properly like I intented to but the listItems does not highlight still.

// scroll to bottom for the list to make sure every item is in the view
if (listview.Items.Count > 1) listview.ScrollIntoView(listview.Items[listview.Items.Count - 1]);

// scroll back to top to make sure everything looks correct
if (listview.Items.Count > 1) listview.ScrollIntoView(listview.Items[0]);
Posted
Updated 27-Feb-18 20:00pm

1 solution

Here is an article from this month that will do what you are asking for; WPF TextBlock Highlighter[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900