IntCalcConverter.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:IntCalcConverter
  3. * 作者:xulisong
  4. * 创建时间: 2019/5/28 14:46:49
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Globalization;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Data;
  14. namespace Test.ChildWindow
  15. {
  16. public class IntCalcConverter: IValueConverter
  17. {
  18. public static IntCalcConverter Instance = new IntCalcConverter();
  19. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  20. {
  21. int returnValue = System.Convert.ToInt32(value);
  22. if (parameter != null)
  23. {
  24. int calcValue = System.Convert.ToInt32(parameter);
  25. returnValue = returnValue+calcValue;
  26. }
  27. return returnValue;
  28. }
  29. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  30. {
  31. return System.Convert.ToInt32(parameter);
  32. }
  33. }
  34. }