BoolToHeightConverter.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Data;
  7. using System.Windows.Media;
  8. namespace Venus_MainPages.Converters
  9. {
  10. internal class BoolToHeightConverter : IValueConverter
  11. {
  12. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  13. {
  14. if (value == null) return System.Windows.GridLength.Auto;
  15. var item = (bool)value;
  16. if (item == true)
  17. {
  18. return System.Windows.GridLength.Auto;
  19. }
  20. else
  21. {
  22. return new System.Windows.GridLength(0);
  23. }
  24. }
  25. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  26. {
  27. return null;
  28. }
  29. }
  30. internal class BoolToHeightConverter2 : IValueConverter
  31. {
  32. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  33. {
  34. var item = (bool)value;
  35. if (item == true)
  36. {
  37. return new System.Windows.GridLength();
  38. }
  39. else
  40. {
  41. return new System.Windows.GridLength(0);
  42. }
  43. }
  44. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  45. {
  46. return null;
  47. }
  48. }
  49. }