/*------------------------------------------------------------------------- * 功能描述:IntCalcConverter * 作者:xulisong * 创建时间: 2019/5/28 14:46:49 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; namespace Test.ChildWindow { public class IntCalcConverter: IValueConverter { public static IntCalcConverter Instance = new IntCalcConverter(); public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int returnValue = System.Convert.ToInt32(value); if (parameter != null) { int calcValue = System.Convert.ToInt32(parameter); returnValue = returnValue+calcValue; } return returnValue; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return System.Convert.ToInt32(parameter); } } }