I am working with WPF+MVVM
.
I have a VM
which contains a Customer
property. The Customer
has an ObservableCollection
of Orders
. Each Order
has an ObservableCollection
of Items
. Each Items
has a Price
.
Now, I have the following property on my VM
:
public double TotalPrice
{
return Customer.Orders.Sum(x => x.Items.Sum(y => y.Price));
}
The problem is whenever a change occurs at any point in this graph of objects - the UI should be notified that TotalPrice
had changed - but it doesn't...
For example if the Customer
will be altered from A to B, or an order will be added, or an item will be deleted, or an item's price will be altered etc.
Does anyone has an elegant solution for this?
Thanks.