using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; namespace Aitex.Smart.UI.Converters { public class ToNumConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return 0; double ret; if (double.TryParse(value.ToString(), out ret)) return ret; return 0; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion } public class TwoPointNumConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return "-"; double ret; if (double.TryParse(value.ToString(), out ret)) return ret.ToString("F1"); return "-"; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion } }