/// Represents the converter that converts Boolean values to and from Visibility enumeration values.
public sealed class BooleanToVisibilityConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
bool flag = false;
if (value is bool)
flag = (bool)value;
else if (value is bool?)
bool? nullable = (bool?)value;
flag = nullable.HasValue ? nullable.Value : false;
return (flag ? Visibility.Visible : Visibility.Collapsed);
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
return ((value is Visibility) && (((Visibility)value) == Visibility.Visible));
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Microsoft bets on Windows XP disaster