Another one bite the search-bar-list component thing :S

clopezclopez ESMember ✭✭

Hello again:

I was looking for a way to look for something in a looooong list. I have a list of users that initially I put on a picker. It worked fine untill the list started to grow and grow and...
So I'm at the point to need a search bar or something. I don't want to open a new page for this (that could be the easiest an reccomended way for a noob like me), and custom renderers are too much for me right now (I think).

Yes, I did a search on Internet, and yes I'll be looking and reading while I'm waiting for answers, but I want to do something like the image of the first message of this for current page:

I was thinking in using the info from here:
For adding a searchbar or a text entry, and use OnPropertyChanged to manually filter the picker list, but it means writing on the text box, and then open the picker to check for the user (if there's any). Also, I don't know if a mobile device can handle that kind of searchs in real time.

I was reading something about "composition" or "heritance" to create a mixed/hybrid control, but I can't find specific info about it, specially for cross-platform programming, so it could be great if someone can point me in the direction to make a controller that mix a textbox with an scrollable list of something (labels will be enough) that I can refresh with OnPropertyChanged.

Or just some advices can be helpful, anyway.
Thank you.


  • seanydaseanyda GBMember ✭✭✭✭✭

    You're going to want to do something similar to this (firing a refresh on the TextChanged event on an entry).

    SearchBar sb = new SearchBar { Placeholder = "Search Customers" };
                        sb.TextChanged += (sender, e) =>
                            if (sb.Text == "" || sb.Text == null) customerList.ItemsSource = customerDataGroup;
                            List<UserCustomer> testList = new List<UserCustomer>();
                            testList = confirmedList.Where(w => w.Name.Contains(sb.Text)).ToList();
                            List<UserCustomer> test = new List<UserCustomer>();
                            foreach (var item in testList)
                                    IEnumerable<UserCustomer> selectedCustomer = App.localDatabase.Query<UserCustomer>("SELECT * FROM [UserCustomer] WHERE [Name] = '" + item.Name + "'");
                                    // do nothing

    This was filtering data in my sqlite database. Bad code I wrote a while ago but it does the job. You can just use System.Linq to filter normal lists something like

    customerList.ItemsSource = customerDataGroup.Where(w => w.Name.Contains(sb.Text));

  • clopezclopez ESMember ✭✭
    edited October 23

    Yes, I already got that part (second and third links). The problem comes from the user interface and the way to put the information on screen.

Sign In or Register to comment.