using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Data; namespace Aucma.Core.Palletiz.ConvertTo { public class StringToIntConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value?.ToString(); // 将整数转换为字符串 } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { int result; if (int.TryParse(value?.ToString()?.Split(':')[1]?.Trim(), out result)) { return result; // 将字符串转换为整数 } return DependencyProperty.UnsetValue; } } }