I have a master-detail relationship in some custom entities. Say I have the following structure:
class Master : INotifyPropertyChanged
{
public int Id { get; set; } // + property changed implementation
public string Name { get; set; } // + property changed implementation
public ObservableCollection<Detail> Details { get; }
public long sumValue{get{return Details.Sum(x=>x.value -x.discount );}}
}
class Detail : INotifyPropertyChanged
{
public int Id { get; private set; }
public string Description { get; set; }
public double Discont{ get; set; } // + property changed implementation
public double Value { get; set; } // + property changed implementation
}
if i change row 5 in detail discount Or value How can refresh sumValue?
i add row 1 and set amount 1 and row sum row is 2000
and add new row 2 set amount 5 and row sum is 10000
but sum in master frezz on last row 2000!
if i call
NotifyPropertyChange("sumValue");
from master ui updated sumvalue Property!
how can i use
NotifyPropertyChange("sumValue");
from master Property in Detail Property
like this:
public double Discont{ get{ return _discount } set{_discount = value; NotifyPropertyChange("sumValue");} }