/// <summary> /// when pages are opened, update them /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void TabbedPage_CurrentPageChanged(object sender, EventArgs e) { var index = (TabID)this.Children.IndexOf(this.CurrentPage); // If your called method requires async code in initialization, define an "IsLoading" property in your page and change and check that accordingly switch (index) { case TabID.profilePage: { ProfilePage profilePage = (ProfilePage)this.TabbedPagePage.Children[(int)TabID.profilePage]; if (!profilePage.IsLoading && !profilePage.IsOnLoginPage) { await profilePage.UpdateProfilePageAsync(); } } break; } }
/// <summary> /// When the user wants to create a brand new quiz /// </summary> /// <param name="sender"> </param> /// <param name="e"> </param> private async void ButtonCreateQuiz_Activated(object sender, EventArgs e) { if (CredentialManager.IsLoggedIn) { CreateNewQuizPage quiz = new CreateNewQuizPage(); await this.Navigation.PushAsync(quiz); } else { if (await this.DisplayAlert("Hold on!", "Before you can create your own custom quizzes, you have to create your own account.", "Login/Create Account", "Go Back")) { ProfilePage profilePage = new ProfilePage(); if (!profilePage.IsLoading && !profilePage.IsOnLoginPage) { await profilePage.UpdateProfilePageAsync(); } profilePage.SetTemporary(); await this.Navigation.PushAsync(profilePage); } } }