DoubleToGridLength.cs 727 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Data;
  9. namespace GeekDesk.Converts
  10. {
  11. class DoubleToGridLength : IValueConverter
  12. {
  13. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  14. {
  15. double val = double.Parse(value.ToString());
  16. return new GridLength(val);
  17. }
  18. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. GridLength val = (GridLength)value;
  21. return double.Parse(val.ToString());
  22. }
  23. }
  24. }