/// <summary> /// Loads and deserializes a saved CareerFair object which it uses to populate the model /// </summary> private void Load() { OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Filter = "cfair files (*.cfair)|*.cfair"; openDialog.RestoreDirectory = true; Nullable <bool> result = openDialog.ShowDialog(); if (result == true) { // Load document string filename = openDialog.FileName; System.IO.FileStream fs = new FileStream(filename, FileMode.Open); DataContractSerializer dcs = new DataContractSerializer(typeof(CareerFair)); this.CareerFair = (CareerFair)dcs.ReadObject(fs); fs.Close(); RaisePropertyChangedEvent("CareerFair"); DayTabs.Clear(); foreach (EventDay day in this.CareerFair.Days) { DayTabs.Add(new TabItem { Header = day.Name, Content = new EventDayViewModel(day) }); } RaisePropertyChangedEvent("DayTabs"); } }
/// <summary> /// Creates the wrapper classes for the tabs and adds them to the observed collection. /// </summary> private void createTabs() { DayTabs.Clear(); foreach (EventDay day in this.CareerFair.Days) { DayTabs.Add(new TabItem { Header = day.Name, Content = new EventDayViewModel(day) }); } }