blob: da1a408cfb77095f9e700263d48e65fb26ff0404 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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;
}
}
}
|