public class CartItemViewModel : MvxNotifyPropertyChanged
{
public double SubTotal
{
get { return UnitPrice * Quantity; }
set
{
//RaisePropertyChanged("TotalValue")
}
}
}
public class CartViewModel : MvxViewModel
{
public double TotalValue
{
get
{
foreach (var item in cartlist)
{
totalvalue += item.UnitPrice;
}
return totalvalue;
}
set
{
TotalValue = value;
}
}
private double totalvalue;
}
I want to modify TotalValue
property when SubTotal
property is changed. Both are in different classes. How to make it possible?
It is not working when I pop up Raispropertychanged("TotalValue")
in SubTotal
.
Please Help!
You should handle the PropertyChanged
event for all the instances of CartItemViewModel
inside the CartViewModel
.
You receive PropertyChangedEventArgs
which has a member called PropertyName
. When its value is "SubTotal" then you can call Raispropertychanged(TotalValue)
.
The code is completely added to CartViewModel
.