Files
CRSim/CRSim.Shared/Converters/ListToStringConverter.cs
2025-03-16 12:19:30 +08:00

25 lines
815 B
C#

using System.Globalization;
using System.Windows.Data;
namespace CRSim.Shared.Converters
{
public class ListToStringConverter : IValueConverter
{
public string Separator { get; set; } = ""; // 默认分隔符是双引号间隔
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is List<string> ticketChecks)
{
// 使用自定义的 Separator 将字符串连接
return string.Join(Separator, ticketChecks);
}
return string.Empty;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
// 通常不需要实现 ConvertBack
return null;
}
}
}