mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace Wabbajack
|
|
{
|
|
[ValueConversion(typeof(Visibility), typeof(bool))]
|
|
public class BoolToVisibilityHiddenConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (targetType != typeof(Visibility))
|
|
throw new InvalidOperationException($"The target must be of type {nameof(Visibility)}");
|
|
bool compareTo = true;
|
|
if (parameter is bool p)
|
|
{
|
|
compareTo = p;
|
|
}
|
|
else if (parameter is string str && str.ToUpper().Equals("FALSE"))
|
|
{
|
|
compareTo = false;
|
|
}
|
|
return ((bool)value) == compareTo ? Visibility.Visible : Visibility.Hidden;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|