diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index 60c9cd5a..c0f135f5 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -106,6 +106,8 @@ + + diff --git a/HandyControl/Themes/Basic/Converters.xaml b/HandyControl/Themes/Basic/Converters.xaml index a4ae0c09..8a4d418f 100644 --- a/HandyControl/Themes/Basic/Converters.xaml +++ b/HandyControl/Themes/Basic/Converters.xaml @@ -13,5 +13,7 @@ + + \ No newline at end of file diff --git a/HandyControl/Tools/Converter/Boolean2StrConverter.cs b/HandyControl/Tools/Converter/Boolean2StrConverter.cs new file mode 100644 index 00000000..21d30e01 --- /dev/null +++ b/HandyControl/Tools/Converter/Boolean2StrConverter.cs @@ -0,0 +1,32 @@ +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(); + } + } +} \ No newline at end of file diff --git a/HandyControl/Tools/Converter/Int2StrConverter.cs b/HandyControl/Tools/Converter/Int2StrConverter.cs new file mode 100644 index 00000000..3ebfff45 --- /dev/null +++ b/HandyControl/Tools/Converter/Int2StrConverter.cs @@ -0,0 +1,35 @@ +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(); + } + } +} \ No newline at end of file