private void rebindComboBox(QAMode mode) { //rebind the combobox switch (mode) { case QAMode.Answer: cboQorAs.ItemsSource = null; cboQorAs.ItemsSource = answers; break; case QAMode.Question: cboQorAs.ItemsSource = null; cboQorAs.ItemsSource = questions; break; default: break; } cboQorAs.DisplayMemberPath = "Text"; cboQorAs.SelectedValuePath = "Id"; //Update the edit button btnSave.Content = "Add " + qaMode.ToString(); editMode = EditMode.Add; }
public ManageQAs(QAMode mode) { try { InitializeComponent(); //Adjust labels and title for the mode lblQOrA.Content = mode.ToString() + "s:"; Title = "Manage " + mode.ToString() + "s"; //save the mode in a modular level variable qaMode = mode; //Instantiate the proper list switch (mode) { case QAMode.Answer: answers = new AnswerList(); answers.Load(); break; case QAMode.Question: questions = new QuestionList(); questions.LoadQuestions(); break; default: break; } rebindComboBox(mode); //Select the first item in the combobox cboQorAs.SelectedIndex = 0; } catch (Exception ex) { lblStatus.Content = ex.Message; } }