33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace DTS.Common.Converters
|
|
{
|
|
public class BooleanOrToVisibilityMultiConverter : IMultiValueConverter
|
|
{
|
|
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
var useFalseAsVisible = parameter != null && parameter.ToString().ToUpper().Contains("FALSE");
|
|
var hideNotCollapse = parameter != null && parameter.ToString().ToUpper().Contains("HIDE");
|
|
|
|
bool value = !values.All(val => val is bool) ? false : values.Any(val => (bool)val);
|
|
if (useFalseAsVisible)
|
|
{
|
|
if (!value)
|
|
return Visibility.Visible;
|
|
return hideNotCollapse ? Visibility.Hidden : Visibility.Collapsed;
|
|
}
|
|
if (!value)
|
|
return hideNotCollapse ? Visibility.Hidden : Visibility.Collapsed;
|
|
return Visibility.Visible;
|
|
}
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|