BooleanToVisibilityConverter.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. namespace GDNXFD.Alert.Config.Converters
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Data;
  10. /// <summary>
  11. /// Boolean to visibility converter.
  12. /// </summary>
  13. public class BooleanToVisibilityConverter : IValueConverter
  14. {
  15. /// <summary>
  16. /// Converts a boolean value to a visibility value.
  17. /// </summary>
  18. /// <param name="value"></param>
  19. /// <param name="targetType"></param>
  20. /// <param name="parameter"></param>
  21. /// <param name="culture"></param>
  22. /// <returns></returns>
  23. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  24. {
  25. bool val = System.Convert.ToBoolean(value);
  26. if (val)
  27. {
  28. return Visibility.Visible;
  29. }
  30. return Visibility.Collapsed;
  31. }
  32. /// <summary>
  33. /// Not implemented.
  34. /// </summary>
  35. /// <param name="value"></param>
  36. /// <param name="targetType"></param>
  37. /// <param name="parameter"></param>
  38. /// <param name="culture"></param>
  39. /// <returns></returns>
  40. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  41. {
  42. throw new NotImplementedException();
  43. }
  44. }
  45. }