ConvertButtonIsEnable.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Data;
  8. namespace ivf_tl_Operate.Converts
  9. {
  10. public class ConvertButtonIsEnable : IMultiValueConverter
  11. {
  12. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  13. {
  14. try
  15. {
  16. if (values.Count() != 2)
  17. {
  18. return false;
  19. }
  20. var a = values[0];
  21. var b = values[1];
  22. if (a == null || b == null)
  23. {
  24. return false;
  25. }
  26. int selectIndex = int.Parse(a.ToString());
  27. int ItemsCount = int.Parse(b.ToString());
  28. if (parameter.ToString() == "1")//上一页和第一页
  29. {
  30. if (selectIndex > 0)
  31. {
  32. return true;
  33. }
  34. else
  35. {
  36. return false;
  37. }
  38. }
  39. else
  40. {
  41. if (selectIndex < (ItemsCount - 1))
  42. {
  43. return true;
  44. }
  45. else
  46. {
  47. return false;
  48. }
  49. }
  50. }
  51. catch (Exception)
  52. {
  53. return false;
  54. }
  55. }
  56. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  57. {
  58. throw new NotImplementedException();
  59. }
  60. }
  61. }