Files
HandyControl/HandyControl/Tools/Converter/Boolean2StrConverter.cs
T
2018-12-12 10:25:22 +08:00

32 lines
898 B
C#

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