ListCountToVisible.cs.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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;
  8. using System.Windows.Data;
  9. namespace PDF_Office.DataConvert
  10. {
  11. public class ListCountToVisible : IValueConverter
  12. {
  13. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  14. {
  15. if (value == null)
  16. {
  17. return Visibility.Collapsed;
  18. }
  19. else
  20. {
  21. if ((int)value == 0)
  22. {
  23. return Visibility.Visible;
  24. }
  25. else
  26. {
  27. return Visibility.Collapsed;
  28. }
  29. }
  30. }
  31. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  32. {
  33. throw new NotImplementedException();
  34. }
  35. }
  36. public class ListCountAndBoolToVisible : IMultiValueConverter
  37. {
  38. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  39. {
  40. if (values[0] == null || values[1] == null)
  41. {
  42. return Visibility.Collapsed;
  43. }
  44. else
  45. {
  46. if ((int)values[0] == 0 && (bool)values[1])
  47. {
  48. return Visibility.Collapsed;
  49. }
  50. if ((int)values[0] == 0)
  51. {
  52. return Visibility.Visible;
  53. }
  54. else
  55. {
  56. return Visibility.Collapsed;
  57. }
  58. }
  59. }
  60. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  61. {
  62. throw new NotImplementedException();
  63. }
  64. }
  65. }