StringToVisibilityConverter.cs 902 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. using System.Windows;
  9. namespace ComPDFKit.Controls.Common
  10. {
  11. [ValueConversion(typeof(string), typeof(Visibility))]
  12. class StringToVisibilityConverter : IValueConverter
  13. {
  14. #region IValueConverter Members
  15. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  16. {
  17. if ((value as string) == string.Empty)
  18. {
  19. return Visibility.Visible;
  20. }
  21. else
  22. {
  23. return Visibility.Collapsed;
  24. }
  25. }
  26. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  27. {
  28. return null;
  29. }
  30. #endregion
  31. }
  32. }