Files
aistudio-wpf-diagram/Others/Dragablz/Dragablz/Converters/BooleanAndToVisibilityConverter.cs
2023-04-16 20:11:40 +08:00

36 lines
936 B
C#

using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;
namespace Dragablz.Converters
{
public class BooleanAndToVisibilityConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values == null)
return Visibility.Collapsed;
return values.Select(GetBool).All(b => b)
? Visibility.Visible
: Visibility.Collapsed;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return null;
}
private static bool GetBool(object value)
{
if (value is bool)
{
return (bool)value;
}
return false;
}
}
}