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內部的分數變化,以便我可以重新計算通知。Observable collection提高屬性變化
其實我綁定整個實體到一個GridView。每當列中的分數發生變化時,我希望我的總計列自動計算總計並顯示。
非常感謝..我會執行此操作。希望這可以工作。對於錯誤感到抱歉,它必須是Avarage而不是Sum。 – Vinay
嗨,當我添加您的ObservableCollectionEx.cs文件,我得到以下錯誤,無法解析符號ReaderWriterLock。 – Vinay
你使用什麼版本的.NET框架? – chopikadze