/// <include file="../../docs/Microsoft.Maui.Controls/RowDefinitionCollectionTypeConverter.xml" path="//Member[@MemberName='ConvertTo']/Docs" /> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (value is not RowDefinitionCollection rdc) { throw new NotSupportedException(); } var converter = new GridLengthTypeConverter(); return(string.Join(", ", rdc.Select(rd => converter.ConvertToInvariantString(rd.Height)))); }
public override string ConvertToInvariantString(object value) { if (!(value is ColumnDefinitionCollection cdc)) { throw new NotSupportedException(); } var converter = new GridLengthTypeConverter(); return(string.Join(", ", cdc.Select(cd => converter.ConvertToInvariantString(cd.Width)))); }
public override string ConvertToInvariantString(object value) { if (!(value is RowDefinitionCollection rdc)) { throw new NotSupportedException(); } var converter = new GridLengthTypeConverter(); return(string.Join(", ", rdc.Select(rd => converter.ConvertToInvariantString(rd.Height)))); }
public override object ConvertFromInvariantString(string value) { if (value != null) { var lengths = value.Split(','); var coldefs = new ColumnDefinitionCollection(); var converter = new GridLengthTypeConverter(); foreach (var length in lengths) { coldefs.Add(new ColumnDefinition { Width = (GridLength)converter.ConvertFromInvariantString(length) }); } return(coldefs); } throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(ColumnDefinitionCollection))); }
/// <include file="../../docs/Microsoft.Maui.Controls/RowDefinitionCollectionTypeConverter.xml" path="//Member[@MemberName='ConvertFrom']/Docs" /> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var strValue = value?.ToString(); if (strValue != null) { var lengths = strValue.Split(','); var coldefs = new RowDefinitionCollection(); var converter = new GridLengthTypeConverter(); foreach (var length in lengths) { coldefs.Add(new RowDefinition { Height = (GridLength)converter.ConvertFromInvariantString(length) }); } return(coldefs); } throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", strValue, typeof(RowDefinitionCollection))); }
/// <include file="../../docs/Microsoft.Maui.Controls/ColumnDefinitionCollectionTypeConverter.xml" path="//Member[@MemberName='ConvertFrom']/Docs" /> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var strValue = value?.ToString(); if (strValue != null) { var lengths = strValue.Split(','); var converter = new GridLengthTypeConverter(); var definitions = new ColumnDefinition[lengths.Length]; for (var i = 0; i < lengths.Length; i++) { definitions[i] = new ColumnDefinition { Width = (GridLength)converter.ConvertFromInvariantString(lengths[i]) } } ; return(new ColumnDefinitionCollection(definitions)); } throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", strValue, typeof(ColumnDefinitionCollection))); }