private void btnAdd_Click(object sender, RoutedEventArgs e) { AddTestItemWindow addWindow = new AddTestItemWindow(); addWindow.Owner = this; if (addWindow.ShowDialog() == true) { testList = testManagerBLL.GetModelList(""); Binding b = new Binding() { Source = testList }; cbTestItems.SetBinding(ComboBox.ItemsSourceProperty, b); cbTestItems.SelectedIndex = 0; } }
//添加 private void imgAdd_MouseDown(object sender, MouseButtonEventArgs e) { AddTestItemWindow addWindow = new AddTestItemWindow(); addWindow.Owner = Application.Current.MainWindow; if (addWindow.ShowDialog() == true) { selectedTestItemIndex = 0; RefrenshList(); } }
//修改 private void imgEdit_MouseDown(object sender, MouseButtonEventArgs e) { if (testItmesListBox.SelectedIndex >= 0) { AddTestItemWindow addWindow = new AddTestItemWindow(); addWindow.Owner = Application.Current.MainWindow; addWindow.TestItem = testList[testItmesListBox.SelectedIndex]; if (addWindow.ShowDialog() == true) { RefrenshList(); } } else { MessageBox.Show("请选择一项编辑!"); } }