//Függvény, ami meghívódik, ha a MainPage lesz az aktív View public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { //A visszagomb letiltása, hiszen a főoldalról nem tudunk visszább menni SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Disabled; //Új service indítása, colletion-ök feltöltése var service = new GoTService(); var books = await service.GetBooksAsync(); foreach (var b in books) { Books.Add(b); } var characters = await service.GetCharactersAsync(); foreach (var c in characters) { Characters.Add(c); } var houses = await service.GetHousesAsync(); foreach (var h in houses) { Houses.Add(h); } await base.OnNavigatedToAsync(parameter, mode, state); }
//On navigation, fills up the collection with books public async override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { var service = new GoTService(); var books = await service.GetBooksAsync(); foreach (var b in books) { Books.Add(b); } await base.OnNavigatedToAsync(parameter, mode, state); }
//Load the parameter and/or the whole list. protected override async void OnNavigatedTo(NavigationEventArgs e) { var arg = e.Parameter as Book; //If we have to load a book if (arg != null) { LoadingRing.IsActive = true; showBookInfo(arg); LoadingRing.IsActive = false; } //After that, load the whole list if has not been loaded yet if (BooksList.Count() == 0) { Books_Searchbox.IsEnabled = false; var service = new GoTService(); LoadingRing.IsActive = true; var books = await service.GetBooksAsync(1); int page = 2; while (books.Count() != 0) { foreach (var item in books) { if (item.name != "") { BooksList.Add(item); } } books = await service.GetBooksAsync(page); page++; } LoadingRing.IsActive = false; Books_Searchbox.IsEnabled = true; } BooksListBox.ItemsSource = BooksList; }