private void CreateStudent_Click(object sender, RoutedEventArgs e) { var selectedIndex = StudentsListBoxView.SelectedIndex; if (selectedIndex == -1) { var studentEditor = new StudentEditor(); studentEditor.Show(); } }
private void StudentsListView_DoubleClick(object sender, MouseEventArgs e) { var selectedIndex = StudentsListBoxView.SelectedIndex; var studentsListBox = e.Source as ListBoxItem; var item = ((FrameworkElement)e.OriginalSource).DataContext as Student; var selectedStudent = StudentsListBoxView.Items.GetItemAt(selectedIndex) as Student; var studentEditor = new StudentEditor(selectedStudent); studentEditor.Owner = Application.Current.MainWindow; studentEditor.Show(); }