Files
HandyControl/Net40/HandyControl_Net40/Tools/Converter/Int2StrConverter.cs
T
2019-01-21 11:12:38 +08:00

35 lines
903 B
C#

using System;
using System.Globalization;
using System.Windows.Data;
namespace HandyControl.Tools.Converter
{
public class Int2StrConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int intValue)
{
if (parameter is string str)
{
var arr = str.Split(';');
if (arr.Length > intValue)
{
return arr[intValue];
}
return intValue;
}
return intValue;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}