IntToVisibilityConverter.cs 1000 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Data;
  7. namespace Muchinfo.MTPClient.Infrastructure.Converters
  8. {
  9. /// <summary>
  10. /// 通用判断有值且大于零的显示,否则隐藏
  11. /// </summary>
  12. public class IntToVisibilityConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  15. {
  16. if (value == null || value.ToString() == "")
  17. {
  18. return Visibility.Collapsed;
  19. }
  20. if (decimal.Parse(value.ToString()) > 0)
  21. {
  22. return Visibility.Visible;
  23. }
  24. return Visibility.Collapsed;
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. }
  31. }