ImageExistenceToRowHeightConverter .cs 1008 B

1234567891011121314151617181920212223242526272829303132333435
  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 MV485.helper
  9. {
  10. public class ImageExistenceToRowHeightConverter : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  13. {
  14. // 判断图片路径是否为空或空字符串
  15. string imagePath = value as string;
  16. if (string.IsNullOrEmpty(imagePath))
  17. {
  18. // 图片不存在,返回行高30
  19. return 100;
  20. }
  21. else
  22. {
  23. // 图片存在,返回行高60
  24. return 200;
  25. }
  26. }
  27. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  28. {
  29. // 不需要实现ConvertBack
  30. throw new NotImplementedException();
  31. }
  32. }
  33. }