ModernWpfPlayground/PixelsToGridLengthConverter.cs
2020-02-10 22:15:28 +01:00

20 lines
596 B
C#

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace ModernWpfPlayground
{
public class PixelsToGridLengthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is double d ? new GridLength(d) : new GridLength(1.0, GridUnitType.Auto);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}