25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

  1. using BPA.UIControl.Commons;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Data;
  10. namespace BPA.UIControl.Converters
  11. {
  12. /// <summary>
  13. /// Visibility -> bool
  14. /// </summary>
  15. public class VisibilityToBooleanConverter : IValueConverter
  16. {
  17. /// <inheritdoc/>
  18. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. return ConvertVisibilityToBool(value);
  21. }
  22. internal static bool ConvertVisibilityToBool(object value)
  23. {
  24. Visibility visibility = ValidateArgument.NotNullOrEmptyCast<Visibility>(value, "value");
  25. return visibility == Visibility.Visible;
  26. }
  27. /// <inheritdoc/>
  28. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  29. {
  30. bool flag = ValidateArgument.NotNullOrEmptyCast<bool>(value, "value");
  31. return flag ? Visibility.Visible : Visibility.Collapsed;
  32. }
  33. }
  34. }