答案 0 :(得分:1)
您应该创建一个这样的自定义转换器:
public sealed class StringIsNullOrWhiteSpaceToVisibilityInvertedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return string.IsNullOrWhiteSpace((string)value) ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}