Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Hi there I believe you are going around this the correct way you just need to go a step further. Here are how would expect the classes to look:</p> <p>Chip</p> <pre><code>public class Chip : INotifyPropertyChanged { private int numberPerPlayer; public int NumberPerPlayer { get { return numberPerPlayer; } set { if (numberPerPlayer != value) { numberPerPlayer = value; OnPropertyChanged("NumberPerPlayer"); OnPropertyChanged("TotalValuePerPlayer"); } } } private decimal chipValue; public decimal ChipValue { get { return chipValue; } set { if (chipValue != value) { chipValue = value; //all columns that are based on this need to be updated OnPropertyChanged("ChipValue"); OnPropertyChanged("TotalValuePerPlayer"); } } } public decimal TotalValuePerPlayer { get { return chipValue * numberPerPlayer; } } public event PropertyChangedEventHandler PropertyChanged; public void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } </code></pre> <p>ChipSet</p> <pre><code>public class ChipSet : INotifyPropertyChanged { public ChipSet() { foreach (var chip in Chips) { chip.PropertyChanged += (s, e) =&gt; { OnPropertyChanged("TotalTotalValuePerPlayer"); }; } } public ObservableCollection&lt;Chip&gt; Chips { get; set; } public decimal TotalTotalValuePerPlayer { get { return Chips.Sum(x =&gt; x.TotalValuePerPlayer); } } public void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public event PropertyChangedEventHandler PropertyChanged; } </code></pre> <p>I have not tested this fully but it should point you in the right direction. Hope it helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload