using System; using System.Windows; using System.Windows.Data; namespace Configuration.Converter { public class NullToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (targetType != typeof(Visibility)) throw new InvalidOperationException("The target is not of type bool"); return ((object)value != null) ? Visibility.Visible : Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotSupportedException(); } } }