Files
GeekDesk/Converts/DoubleToGridLength.cs

27 lines
727 B
C#
Raw Normal View History

2021-05-28 18:01:19 +08:00
using System;
2021-05-21 17:19:46 +08:00
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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
}
}
}