Files
GeekDesk/Converts/DoubleToGridLength.cs

23 lines
625 B
C#
Raw Permalink Normal View History

2021-05-28 18:01:19 +08:00
using System;
2021-05-21 17:19:46 +08:00
using System.Globalization;
2021-05-28 18:01:19 +08:00
using System.Windows;
2021-05-21 17:19:46 +08:00
using System.Windows.Data;
2021-05-28 18:01:19 +08:00
namespace GeekDesk.Converts
2021-05-21 17:19:46 +08:00
{
2021-05-28 18:01:19 +08:00
class DoubleToGridLength : IValueConverter
2021-05-21 17:19:46 +08:00
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
2021-05-28 18:01:19 +08:00
double val = double.Parse(value.ToString());
return new GridLength(val);
2021-05-21 17:19:46 +08:00
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
2021-05-28 18:01:19 +08:00
GridLength val = (GridLength)value;
return double.Parse(val.ToString());
2021-05-21 17:19:46 +08:00
}
}
}