private ObservableCollection<Scores> _scores;
public ObservableCollection<Scores> Scores
{
get
{
return _scores;
}
set
{
_scores = value;
RaisePropertyChanged("Scores");
Recalculate();
}
}
public int RowNumber { get; set; }
public string StudentId { get; set; }
public string StudentName { get; set; }
private double _studentAverage;
public double StudentAverage
{
get
{
return _studentAverage;
}
set
{
_studentAverage = value;
RaisePropertyChanged("StudentAverage");
}
}
private string _gradeYear;
public string GradeYear
{
get
{
return _gradeYear;
}
set
{
_gradeYear = value;
RaisePropertyChanged("StudentGrade");
}
}
private void Recalculate()
{
StudentAverage = (from score in Scores select score.Score).Sum();
}
嗨,当 ObservableCollection 中的分数发生变化时,我怎样才能得到通知,以便我可以重新计算。
实际上,我将整个实体绑定到 Gridview。每当列中的分数发生变化时,我希望我的总计列自动计算总计并显示。