I've one ViewModel that has a property. This property is a "PhysicalValue". This PhysicalValue is a class that is composed from a Value and an Unit.
public Class MyViewModel:INotifyPropertyChanged:IDataErrorInfo {
public PhysicalValue Target {get => _target; set => {_target = value; NotifyPropertyChanged("Target");}}
public string this[string columnName]
{
get
{
if (columnName == "Target")
{
if(_target.Value>5000){
return "out of spec value";
}
}
return String.Empty;
}
}
}
I've one control that should edit the value of this PhysicalValue:
[...]
<dxe:TextEdit EditValue="{Binding Target.Value, ValidatesOnDataErrors =true}"></dxe:TextEdit>
[...]
But I've no error for it(probably because it search for Target.Value
for an error. I've tried another approach, bind directly to Target
, but this doesn't work, because I need the convertBack to known which Unit was used originally to rebuild a PhysicalValue.
How would you solve this?