StringEmptyToVisibilityConverter.cs 746 B

12345678910111213141516171819202122232425
  1. using SWRIS.Extensions;
  2. using System;
  3. using System.Globalization;
  4. using System.Windows;
  5. using System.Windows.Data;
  6. namespace SWRIS.Converters
  7. {
  8. public class StringEmptyToVisibilityConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  11. {
  12. if (value == null || !(value is string message))
  13. {
  14. return Visibility.Collapsed;
  15. }
  16. return message.IsNullOrEmpty() ? Visibility.Collapsed : Visibility.Visible;
  17. }
  18. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. throw new NotImplementedException();
  21. }
  22. }
  23. }