using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Windows.Data; namespace Tree { [ValueConversion(typeof(List), typeof(string))] public class ListToStringConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return ""; } var list = (List) value; return String.Join(",", list); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return new List(); } var s = (string) value; string[] ss = s.Split(','); return ss.ToList(); } } }