| File: GridLengthCollectionDesignTypeConverter.cs | Web Access |
| Project: src\src\Controls\src\Core.Design\Controls.Core.Design.csproj (Microsoft.Maui.Controls.DesignTools) |
using System; using System.ComponentModel; using System.Linq; namespace Microsoft.Maui.Controls.Design { public class GridLengthCollectionDesignTypeConverter : TypeConverter { // This tells XAML this converter can be used to process strings // Without this the values won't show up as hints public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) => sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); public override bool IsValid(ITypeDescriptorContext context, object value) { if (value?.ToString() is string strValue) { string[] lengths = strValue.Split(','); return lengths.All(GridLengthDesignTypeConverter.IsValid); } return false; } } }