You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
809 B
27 lines
809 B
3 years ago
|
using System;
|
||
|
using System.Globalization;
|
||
|
using System.Windows;
|
||
|
using System.Windows.Data;
|
||
|
|
||
|
namespace BBWY.Client.Converters
|
||
|
{
|
||
|
public class InputNumberConverter : IValueConverter
|
||
|
{
|
||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
|
{
|
||
|
return value;
|
||
|
}
|
||
|
|
||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
|
{
|
||
|
string strValue = value as string;
|
||
|
if (string.IsNullOrEmpty(strValue))
|
||
|
return null;
|
||
|
decimal result;
|
||
|
if (strValue.IndexOf('.') == strValue.Length - 1 || !decimal.TryParse(strValue, out result))
|
||
|
return DependencyProperty.UnsetValue;
|
||
|
return result;
|
||
|
}
|
||
|
}
|
||
|
}
|