protected async override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { InOrphan = (Orphan)e.Parameter; isNew = false; } else { isNew = true; } GuardianItems.Clear(); var data = await GuardianDataService.AllGuardians(); foreach (var item in data) { GuardianItems.Add(item); } if (InOrphan != null && InOrphan.Guardian != null) { SelectedGuardian = GuardianItems.First(g => g.GuardianID == InOrphan.GuardianID); } base.OnNavigatedTo(e); }
private async void btnDelete_Click(object sender, RoutedEventArgs e) { // Delete confirmation if (Selected != null) { ContentDialog notifyDelete = new ContentDialog() { Title = "Confirm delete?", Content = "Are you sure you wish to delete " + Selected.FullName + "?", PrimaryButtonText = "Delete Guardian", SecondaryButtonText = "Cancel" }; ContentDialogResult result = await notifyDelete.ShowAsync(); if (result == ContentDialogResult.Primary) { // Delete GuardianDataService.DeleteGuardian(Selected); // Clear search text box // Can't get to it because it's inside a data template! // Repopulate the list LoadGuardians(); } else { // User pressed Cancel or the back arrow. } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { Guardian outGuardian = new Guardian(); if (!isNew) { outGuardian = InGuardian; } outGuardian.FirstName = txtFirstName.Text; outGuardian.LastName = txtLastName.Text; outGuardian.FullName = txtFirstName.Text + " " + txtLastName.Text; outGuardian.Location = txtLocation.Text; if (isNew) { // Update to Database GuardianDataService.AddGuardian(outGuardian); } else { // Go get the one of interest, then overwrite. // Update to Database GuardianDataService.SaveGuardian(outGuardian); } // Go Back On_BackRequested(); }
private async void LoadGuardians() { GuardianItems.Clear(); var data = await GuardianDataService.AllGuardians(); foreach (var item in data) { GuardianItems.Add(item); } if (MasterDetailsViewControl.ViewState == MasterDetailsViewState.Both) { Selected = GuardianItems.FirstOrDefault(); } }
private async void GuardianMasterDetailPage_Loaded(object sender, RoutedEventArgs e) { GuardianItems.Clear(); var data = await GuardianDataService.AllGuardians(); foreach (var item in data) { GuardianItems.Add(item); } if (MasterDetailsViewControl.ViewState == MasterDetailsViewState.Both) { Selected = GuardianItems.FirstOrDefault(); } }