private void delete_btn_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this record?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { var student = studDataGrid.SelectedIndex; studVM.OnDelete(student); } }