public static ColumnDefinitions FromString(String val) { var coll = new ColumnDefinitions(); if (val.StartsWith("Repeat")) { var regex = new Regex(@"^Repeat\((.+)\)$"); var match = regex.Match(val.Trim()); if (match.Groups.Count < 2) { throw new XamlException($"Invalid repeat value '{val}'"); } var w = GridLength.FromString(match.Groups[1].Value.Trim()); var cd = new ColumnDefinition() { Width = new GridLength($"repeat(auto-fit, {w})") }; coll.Add(cd); } else { foreach (var row in val.Split(',')) { var cd = new ColumnDefinition() { Width = GridLength.FromString(row.Trim()) }; coll.Add(cd); } } return(coll); }
public static ColumnDefinitions FromString(String val) { var coll = new ColumnDefinitions(); foreach (var row in val.Split(',')) { var cd = new ColumnDefinition { Width = GridLength.FromString(row.Trim()) }; coll.Add(cd); } return(coll); }
public override Object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) { if (value == null) { return(null); } if (value is ColumnDefinitions) { return(value); } else if (value is String) { return(ColumnDefinitions.FromString(value.ToString())); } return(base.ConvertFrom(context, culture, value)); }