MauiEx icon indicating copy to clipboard operation
MauiEx copied to clipboard

Match highlighting on the results

Open dejanbasic opened this issue 5 years ago • 5 comments

Hello, I need to implement highlighting of search query on the matched results. Is there a way to do that?

dejanbasic avatar Jul 09 '19 10:07 dejanbasic

I don't think any of the native controls used supports this, so I don't see a way to do this

dotMorten avatar Jul 09 '19 13:07 dotMorten

This is Syncfusion Xamarin.Forms Autocomplete control:

How they do this?

dejanbasic avatar Jul 10 '19 07:07 dejanbasic

@dejanbasic I'm guessing they don't rely on native controls but custom forms control?

dotMorten avatar Nov 12 '19 05:11 dotMorten

Notes: iOS example using attributed text: https://github.com/dinarajas/HighlightLabel/blob/master/classes/HighlightLabel.m

dotMorten avatar Nov 12 '19 05:11 dotMorten

I implemented my own custom solution in Xamarin.Forms, which looks like this:

Screenshot 2019-11-13 at 13 35 55

I used Entry control for search box and ListView for showing search results. I managed to highlight matched results, by using Label->FormattedText->FormattedString->Span controls, to split text into three parts: first part, highlighted text and last part.

dejanbasic avatar Nov 13 '19 13:11 dejanbasic