public ContactListViewModel(ContactListProvider contactListProvider) { this.contactListProvider = contactListProvider; CollectionViewSource.GetDefaultView(ContactList).Filter = o => { var contactDetail = (ContactDetailViewModel)o; return(SearchedText.IsNullOrEmpty() || contactDetail.FirstName.Contains(SearchedText, StringComparison.OrdinalIgnoreCase) || contactDetail.LastName.Contains(SearchedText, StringComparison.OrdinalIgnoreCase)); }; // UpdateContactList(); }
public void Search() { if (!string.IsNullOrEmpty(SearchedText)) { //Variable that searches through RecentDoctors var results = RecentDoctors.Where(x => x.DoctorsName.ToLower().Contains(SearchedText.ToLower()) || x.Specialization.ToLower().Contains(SearchedText.ToLower())); SearchResults.Clear(); foreach (RecentDoctorsInfo item in results) { SearchResults.Add(item); } } else { //This removes items when you clean the text from the SearchBar SearchResults.Clear(); } }
private void SearchCommand() { if (SearchedText != "") { var tempName = _enregistrementsInDb.Where(e => e.Name.ToLower().Contains(SearchedText.ToLower())); var tempTags = _enregistrementsInDb.Where(e => e.StringTags.ToLower().Contains(SearchedText.ToLower())); EnregistrementsDisplayed.Clear(); foreach (var item in tempName) { EnregistrementsDisplayed.Add(item); } foreach (var item in tempTags) { if (!EnregistrementsDisplayed.Contains(item)) { EnregistrementsDisplayed.Add(item); } } } else { Reset(); } }
private void FilterMaintenance(object param) { if (!string.IsNullOrWhiteSpace(SearchedText)) { AllMaintenanceFiltered = new ObservableCollection <CarPresalesMaintenance>(AllMaintenanceFiltered.Where(kl => kl.RegNr.ToLower().StartsWith(SearchedText.ToLower()))); } else { if (SelectedEmployee == null) { AllMaintenanceFiltered = new ObservableCollection <CarPresalesMaintenance>(AllMaintenance); } else { AllMaintenanceFiltered = new ObservableCollection <CarPresalesMaintenance>(AllMaintenance.Where(rid => rid.Employee.Id == SelectedEmployee.Id)); } } }