using System; using System.Globalization; using System.Windows; using System.Windows.Data; namespace MultiTerm.Wpf.CustomControl; /// /// Converts to . /// If true = Visible, false = Colapsed /// [ValueConversion(typeof(bool), typeof(Visibility))] internal class BoolToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if(value is not bool boolVal) { throw new ArgumentException($"{nameof(BoolToVisibilityConverter)}.{nameof(Convert)} got type other than bool."); } if (boolVal) { return Visibility.Visible; } else { return Visibility.Collapsed; } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }