AntiStringToVisibilityConverter.cs 905 B

12345678910111213141516171819202122232425262728293031323334
  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 AntiStringToVisibilityConverter : 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. }