using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace 智慧物流软件系统
{
    public class ListToString : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return "";

            if (value is string)
            {
                return value.ToString();
            }
            else if (value is List<string>)
            {
                List<string> strList = new List<string>();
                string sep = parameter == null ? "," : parameter.ToString();

                foreach (var item in value as List<string>)
                {
                    strList.Add(item.ToString());
                }

                return string.Join(sep, strList);
            }

            return "";
        }


        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}
