Files
2026-10-27 14:35:03 +08:00

16 lines
628 B
C#

using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Store.Management.Framework.Converters;
/// <summary>空字符串或 null 显示占位内容,其他值折叠;仅用于单向绑定。</summary>
public sealed class StringNullOrEmpty2VisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
=> value is null || value is string { Length: 0 } ? Visibility.Visible : Visibility.Collapsed;
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> Binding.DoNothing;
}