| 1234567891011121314151617181920212223242526272829303132333435363738394041 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Data;namespace Aitex.UI.RecipeEditor{    public class NumConverter :IValueConverter    {        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)        {            try            {                string s = (string)value;                decimal d;                if (!decimal.TryParse(s, out d)) return 0;                return d;            }            catch (Exception ex)            {                System.Diagnostics.Debug.WriteLine(ex.Message);            }            return 0;        }        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)        {            try            {                return value.ToString();            }            catch (Exception ex)            {                System.Diagnostics.Debug.WriteLine(ex.Message);            }            return "0";        }    }}
 |