private async void OrphanMasterDetailPage_Loaded(object sender, RoutedEventArgs e) { await LoadOrphansAsync(); if (MasterDetailsViewControl.ViewState == MasterDetailsViewState.Both) { Selected = OrphanItems.FirstOrDefault(); } }
private void AutoSuggestionBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { orphanList = OrphanItems.ToList(); // Only get results when it was a user typing, // otherwise assume the value got filled in by TextMemberPath // or the handler for SuggestionChosen. if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { // // Boom: David nailed this. // // Added ToLower() calls to normalize text // //Set the ItemsSource to be your filtered dataset listOrphanSuggestion = orphanList.Where(o => o.FullName.ToLower().Contains(sender.Text.ToLower())).ToList(); sender.ItemsSource = listOrphanSuggestion; // // Added this to refresh the items source // MasterDetailsViewControl.ItemsSource = listOrphanSuggestion; } }
private async Task LoadOrphansAsync() { //SampleItems.Clear(); OrphanItems.Clear(); IEnumerable <Orphan> data; // // Use Web API or db directly // if (AppSettings.UseWebApi) { using (HttpClient client = new HttpClient()) { var orphanRepo = new OrphanHttpRepository(client); var parameters = new OrphanParametes { PageNumber = 1, PageSize = 1000 }; var response = await orphanRepo.GetOrphansAsync(parameters); data = response.Orphans.AsEnumerable(); } } else { data = await OrphanDataService.AllOrphans(); using (HttpClient client = new HttpClient()) { var orphanRepo = new PictureHttpRepository(client); var picUrls = await orphanRepo.GetOrphanPicUrls(); foreach (var item in picUrls) { var orphan = data.FirstOrDefault(x => x.OrphanID == item.OrphanID); if (orphan != null) { orphan.ProfilePicUri = item.PicUrl; } } } } //var data = await SampleDataService.GetMasterDetailDataAsync(); //var data = await OrphanDataService.AllOrphans(); foreach (var item in data) { //SampleItems.Add(item); OrphanItems.Add(item); } if (MasterDetailsViewControl.ViewState == MasterDetailsViewState.Both) { Selected = OrphanItems.FirstOrDefault(); LoadNarrationItems(); } }