I have a situation where I have a couple of variables whose values depend on each other as follows:
A is a function of B and C B is a function of A and C C is a function of A and B
Any value can be changed in the user interface. I make a notice of change and change as follows:
private string _valA;
private string _valB;
private string _valC;
public string ValA
{
get { return _valA; }
set
{
if (_valA != value)
{
_valA = value;
RecalculateValues("ValA");
OnPropertyChanged("ValA");
}
}
}
public string ValB
{
get { return _valB; }
set
{
if (_valB != value)
{
_valB = value;
RecalculateValues("ValB");
OnPropertyChanged("ValB");
}
}
}
(...)
private void RecalculateValues(string PropName)
{
if (PropName == "ValA")
{
_valB = TotalValue * _valA;
OnPropertyChanged("ValB");
_valC = something * _valA
OnPropertyChanged("ValC");
}
else
(...)
}
, _valB, _valC (), PropertyChanged .
- , , , . PropertyChanged , , ... , / .
? setter, . ( )?
, , - IdataErrorInfo / . , [columnName] , , , . IDataErrorInfo , (). ?
. ValidationRules , ViewModel.