BoolToHeightConverter.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 CyberX8_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. var item = (bool)value;
  15. if (item == true)
  16. {
  17. return System.Windows.GridLength.Auto;
  18. }
  19. else
  20. {
  21. return new System.Windows.GridLength(0);
  22. }
  23. }
  24. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  25. {
  26. return null;
  27. }
  28. }
  29. internal class BoolToHeightConverter2 : IValueConverter
  30. {
  31. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  32. {
  33. var item = (bool)value;
  34. if (item == true)
  35. {
  36. return new System.Windows.GridLength();
  37. }
  38. else
  39. {
  40. return new System.Windows.GridLength(0);
  41. }
  42. }
  43. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  44. {
  45. return null;
  46. }
  47. }
  48. }