JD2022-TU1/main/tools/framework/JD.WPF/Converters/ListToStringConverter.cs

24 lines
816 B
C#

using System;
using System.Windows.Data;
namespace JD.WPF.Converters
{
public class ListToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value.GetType().GetInterface("IList`1") != null)
{
System.Collections.IList valueAsList = (System.Collections.IList)value;
return $"[{valueAsList.Count} elements]";
}
return new ArgumentException("\"Value\" does not implement IList<> interface. ");
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}