public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var gridLengthConverter = new GridLengthConverter(); var gridLengthRaw = gridLengthConverter.ConvertFrom(parameter); if (gridLengthRaw == null) throw new ArgumentException("Parameter must be convertable to GridLength"); var defaultGridLength = (GridLength)gridLengthRaw; var boolValue = (bool) value; return boolValue ? defaultGridLength : new GridLength(0); }
/// <summary> /// Converts the given object to the type of this converter, using the specified context and culture information. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param> /// <param name="value">The <see cref="T:System.Object" /> to convert.</param> /// <returns> /// An <see cref="T:System.Object" /> that represents the converted value. /// </returns> /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed.</exception> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var s = value as string; if (s != null) { var glc = new GridLengthConverter(); var c = new List<GridLength>(); foreach (var item in s.Split(SplitterChars)) { c.Add((GridLength)glc.ConvertFrom(item)); } return c; } return base.ConvertFrom(context, culture, value); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var converter = new System.Windows.GridLengthConverter(); return(converter.ConvertFrom(value)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return(internalGridLengthConverter.ConvertFrom(value)); }