Skip to content

adityadeshpande/xf-listview-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Search in List View

So basically there are 2 things we need to have

  1. a list view with items in it.
  2. a search bar to input search query on.
and that would be very much of it. in the XAML part, I will just include these 2 things but of course, you can be creative and manipulate the view.

[gist https://gist.github.com/adityadeshpande/1266c996fc35c378f66c395e003dc2e3]

I'm more of an MVVM person and prefer keeping the Code behind clean in the xaml.cs, but you can do it either way, in the ViewModel or Code Behind. this should not matter.

[gist https://gist.github.com/adityadeshpande/9884db9c58e8043c69c9dd4744089d2a]

Android preview. Works on iOS and UWP as well.

In the GetItems method make sure you assign _ItemsUnfiltered = _Items . This makes sure the original contents are not operated on and on clearing the text input of search we can get back the original list. ;) Also, make sure your ViewModel has inheritance of INotifyPropertyChanged so as to hit the OnPropertyChanged(nameof(SomeCommandOrBinding))

That would be very much of the searching thing, you can add as many filter criteria as you want in the lambda expression above. just keep ORing ( A || B ) or ANDing ( A && B ) them. (i prefer ORing).

p.s. I've used an EventToCommandBehavior to bind a command to an event of text changed, you can easily find a code for that. If you don't? feel free to drop by :)

update: Check Binding Event To Command.
Pingback for assistance, your Feedback’s are always a welcome… 🙂

Regards, Aditya Deshpande

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages