using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Tango.PPC.Jobs.Converters { public class DoubleNullConverter : System.Windows.Data.IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if(parameter is string && (string)parameter == "1") { return value is null ? "0" : double.TryParse(value.ToString(), out var pvalueResult) ? pvalueResult.ToString("0.##") : ""; } return value is null ? "-" : double.TryParse(value.ToString(), out var valueResult) ? valueResult.ToString("0.##") : ""; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { //throw new NotImplementedException(); if(value is double) return value; return 0; } } }