public void DeleteTrainer(string name) { TrainerContainer tc = (TrainerContainer)trainerGrid.SelectedItem; if (tc == null) { return; } if (name == tc.Name) { DataSerializer.DeleteTrainer(tc); data.Remove((TrainerContainer)trainerGrid.SelectedItem); DataSerializer.SaveTrainerContainers(data); } }
private void TrainerGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (dataManager.ActiveTrainer != null) { dataManager.ActiveTrainer.Save(); } foreach (TrainerContainer tc in data) { tc.PropertyChanged -= OnContainerChanged; } TrainerContainer selected = (TrainerContainer)trainerGrid.SelectedItem; if (selected == null) { dataManager.ActiveBox = null; dataManager.ActiveTrainer = null; return; } selected.PropertyChanged += OnContainerChanged; TrainerData trainer = selected.LoadTrainer(); trainer.Container = selected; dataManager.ActiveTrainer = trainer; dataManager.ActiveBox = null; }