Click here to Skip to main content
14,336,318 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100