This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using Avalonia.Data.Converters;
using System;
using System.Globalization;
namespace AI.Converters
{
/// <summary>
/// 将字符串转换为布尔值(非空字符串为 true,空或 null 为 false)
/// </summary>
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();