private void ExecuteOnSearch() { if (string.IsNullOrWhiteSpace(SearchBarText)) { Filtred_List = new ObservableCollection <Products_Model>(Products); } else { var _filtred_List = Products.Where(i => i.name.ToLower().Contains(SearchBarText.ToLower())).ToList(); Filtred_List.Clear(); foreach (var product in _filtred_List) { Filtred_List.Add(product); } } }
private void ExecuteOnSearch() { if (Filtred_list != null) { if (string.IsNullOrWhiteSpace(SearchBarText)) { var sorted = from contact in Filtred_list orderby contact.Name group contact by contact.NameSort into contactGroup select new Grouping <string, Client2>(contactGroup.Key, contactGroup); Contacts = new ObservableCollection <Grouping <string, Client2> >(sorted); } else { if (Filtred_list == null) { Filtred_list = No_Sorted_Contacts; } var filtred_list = Filtred_list.Where(i => i.Name.ToLower().Contains(SearchBarText.ToLower())).ToList(); var sorted = from contact in filtred_list orderby contact.Name group contact by contact.NameSort into contactGroup select new Grouping <string, Client2>(contactGroup.Key, contactGroup); Contacts = new ObservableCollection <Grouping <string, Client2> >(sorted); } } }