private void btnEditGrade_Click(object sender, RoutedEventArgs e) { var grade = dgvGrades.SelectedValue as GradeViewModel; var rights = UserViewModel.CurrentUser.CanEdit(grade); if (RightsEnum.Success != UserViewModel.CurrentUser.CanEdit(grade)) { MessageBox.Show("User can not edit this grade at this stage."); return; } var window = new EditGradeWindow(_student.Name, grade); window.ShowDialog(); RefreshMarks(); }