Search code examples
c#xamarinxamarin.formssearchbar

Need SearchBar to give same result even if its capital letters or not


I need SearchBar to give same result even if its capital letters or not.

This is the code I use to filter:

myList.ItemsSource = wasteList.Where(x => x.WasteType.Contains(e.NewTextValue));

I have also tried following but the results from SearchBar are still different:

myList.ItemsSource = wasteList.Where(x => x.WasteType.ToLower.Contains(e.NewTextValue));
myList.ItemsSource = wasteList.Where(x => x.WasteType.ToUpper.Contains(e.NewTextValue));

Please, does anyone not to make the SearchBar none case sensitive?


Solution

  • Make both of the values ToLower (or ToUpper) and then compare them:

    myList.ItemsSource = wasteList.Where(x => x.WasteType.ToLower.Contains(e.NewTextValue.ToLower));