Visibility2boolConverter.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. using System.Windows.Media;
  7. using System.Windows;
  8. using DataAnalysisControl.Core;
  9. namespace Aitex.UI.Charting.Converter
  10. {
  11. public class Visibility2boolConverter : IValueConverter
  12. {
  13. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  14. {
  15. try
  16. {
  17. Visibility vi = (Visibility)value;
  18. if (vi == Visibility.Visible) return true;
  19. return false;
  20. }
  21. catch (Exception ex)
  22. {
  23. CONTEXT.WriteLog(ex);
  24. }
  25. return true;
  26. }
  27. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  28. {
  29. try
  30. {
  31. bool isChecked = (bool)value;
  32. if (isChecked) return Visibility.Visible;
  33. return Visibility.Hidden;
  34. }
  35. catch (Exception ex)
  36. {
  37. CONTEXT.WriteLog(ex);
  38. }
  39. return Visibility.Visible;
  40. }
  41. }
  42. }