You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
874 B
C#

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.PalletizCX1.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;
}
}
}