// From string to numeric (for the view model) public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { #if FORCE_NULLABLE_DOUBLE var valueEntered = ConvertValueToString(value); if (valueEntered.IsNotEmpty() && double.TryParse(valueEntered, out var valueAsDouble)) { return(valueAsDouble as double?); } #else if (ConvertBackFunc.IsNotNullOrDefault()) { return(ConvertBackFunc(ConvertValueToString(value))); } #endif return(default);
public TypedValueConverterBase(ConvertFunc convertFunc, ConvertBackFunc convertBackFunc = null) { _convertFunc = convertFunc; _convertBackFunc = convertBackFunc; }