private void OnLoad(object sender, RoutedEventArgs e) { try { selectedAssn = GlobalVars.UserAssns[index]; PageTitle.DataContext = selectedAssn.Ename; SubDateHolder.DataContext = selectedAssn.Edate.Date.ToLongDateString(); SubTimeHolder.DataContext = String.Concat(selectedAssn.Etime.Hour.ToString(), ":", selectedAssn.Etime.Minute.ToString(), " hrs"); DetailsHolder.DataContext = selectedAssn.Details; TimeSpan span = selectedAssn.Edate.Subtract(DateTime.Today); if (span.Days < 0) { DayCountdown.Text = Math.Abs(span.Days).ToString(); DayCountdownSubtitle.Text = "day(s) overdue!"; } else { DayCountdown.Text = span.Days.ToString(); } } catch { MessageBox.Show("Page does not exist. Maybe you had deleted something."); NavigationService.GoBack(); } }
private void OnLoad(object sender, RoutedEventArgs e) { try { if (index != -1) { PageTitle.DataContext = "edit details"; using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { List<Assignment> temp = new List<Assignment>(); if (myIsolatedStorage.FileExists("Assignments.xml")) { using (IsolatedStorageFileStream stream1 = new IsolatedStorageFileStream("Assignments.xml", FileMode.Open, FileAccess.Read, myIsolatedStorage)) { XmlSerializer serializer = new XmlSerializer(typeof(List<Assignment>)); temp = (List<Assignment>)serializer.Deserialize(stream1); } ToEdit = temp[index]; if (firstload) { assnNameTbx.DataContext = ToEdit.Ename; subDate.Value = ToEdit.Edate; subTime.Value = ToEdit.Etime; detailsTbx.Text = ToEdit.Details; firstload = false; } } } } else PageTitle.DataContext = "new assignment"; } catch { MessageBox.Show("Oops! Something went wrong. You might have deleted the item on this page."); NavigationService.GoBack(); } }