2025-10-11 18:25:59 +08:00

25 lines
789 B
C#

using System.Globalization;
namespace XiaoZhiSharp_MauiApp.Converters
{
public class BoolToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool boolValue && parameter is string parameters)
{
var options = parameters.Split(';');
if (options.Length == 2)
{
return boolValue ? options[0] : options[1];
}
}
return value?.ToString() ?? string.Empty;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}