//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); }
//Gets a list of characters from the requested pagenumber private async Task GetCharacters() { var service = new GoTService(); var characters = await service.GetCharactersAsync(PageCount); Characters.Clear(); foreach (Character c in characters) { Characters.Add(c); } }
//Load the parameter, if there is one. Else, load the whole list. protected override async void OnNavigatedTo(NavigationEventArgs e) { var arg = e.Parameter as Character; //If we have to load a character if (arg != null) { LoadingRing.IsActive = true; showCharacterInfo(arg); LoadingRing.IsActive = false; } //After loading the character, we proceed to load the list if we have to if (CharactersList.Count() == 0) { Characters_Searchbox.IsEnabled = false; var service = new GoTService(); LoadingRing.IsActive = true; //We need to take all the pages var characters = await service.GetCharactersAsync(1); int page = 2; while (characters.Count != 0) { foreach (var item in characters) { if (item.name != "") { CharactersList.Add(item); } } characters = await service.GetCharactersAsync(page); page++; } LoadingRing.IsActive = false; Characters_Searchbox.IsEnabled = true; } CharactersListBox.ItemsSource = CharactersList; }