You can use the <x:Array> markup extension , but its syntax is pretty verbose.
Another option is to create your own TypeConverter , which can convert from a comma-separated list to an array:
class ArrayTypeConverter : TypeConverter { public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object value) { string list = value as string; if (list != null) return list.Split(','); return base.ConvertFrom(context, culture, value); } public override bool CanConvertFrom( ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) return true; return base.CanConvertFrom(context, sourceType); } }
If the type you converted was your type, you can apply the [TypeConverter] attribute to that type. But since you want to convert to string[] , you cannot do this. Therefore, you must apply this attribute to all properties where you want to use this converter:
[TypeConverter(typeof(ArrayTypeConverter))] public string[] PropName { get; set; }
source share