24 lines
802 B
C#
24 lines
802 B
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace XP.Hardware.PLC.Sentry.Converters
|
|
{
|
|
/// <summary>
|
|
/// 将 null 或空字符串转换为 Collapsed,非空字符串转换为 Visible | Converts null/empty string to Collapsed, non-empty to Visible
|
|
/// </summary>
|
|
public class NullOrEmptyToVisibilityConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return string.IsNullOrEmpty(value as string) ? Visibility.Collapsed : Visibility.Visible;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
}
|
|
}
|