StringToIntConverter.cs 762 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. namespace Muchinfo.MTPClient.Infrastructure.Converters
  7. {
  8. public class StringToIntConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  11. {
  12. decimal result = 0;
  13. if (value != null)
  14. {
  15. decimal.TryParse(value.ToString(), out result);
  16. }
  17. return result;
  18. }
  19. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  20. {
  21. throw new NotImplementedException();
  22. }
  23. }
  24. }