Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

37 righe
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. }