using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; using System.Windows; using System.Collections; using System.Text.RegularExpressions; namespace HeuristicLab.OKB.Cockpit.Query { public class ListFormatter : IValueConverter { private Regex separator = new Regex(@"\s*,\s*"); public Regex Separator { get { return separator; } set { separator = value; } } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { IList lst = value as IList; if (lst == null) return value; return string.Join(", ", lst.Cast().Select(v => v.ToString()).ToArray()); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string s = value as string; if (string.IsNullOrEmpty(s)) return null; return separator.Split((string)value).Cast().ToList(); } } }