using Avalonia.Data.Converters; using System; using System.Globalization; namespace AI.Converters { /// /// 将字符串转换为布尔值(非空字符串为 true,空或 null 为 false) /// public class StringToBoolConverter : IValueConverter { public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is string str) { return !string.IsNullOrWhiteSpace(str); } return false; } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { throw new NotImplementedException(); } } }