StringToVisibilityConverter.cs 915 B

1234567891011121314151617181920212223242526272829303132
  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 StringToVisibilityConverter : 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. else
  21. {
  22. return Visibility.Visible;
  23. }
  24. }
  25. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  26. {
  27. throw new NotImplementedException();
  28. }
  29. }
  30. }