BuyOrSellConvert.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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 BuyOrSellConvert : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  11. {
  12. if (value != null && parameter != null && (int)value == int.Parse(parameter.ToString())) ////值相等的
  13. {
  14. return true;
  15. }
  16. return false;
  17. }
  18. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  19. {
  20. if (value.Equals(true))
  21. {
  22. var result = Enum.Parse(targetType, parameter.ToString());
  23. return result;
  24. }
  25. else
  26. { ////设置值时不进行赋值
  27. var result = Enum.Parse(targetType, "-1");
  28. return result;
  29. }
  30. }
  31. }
  32. }