39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace NfcC7_DLL.NfcHanler.Utils
|
|
{
|
|
[ValueConversion(typeof(bool), typeof(Visibility))]
|
|
public class BoolToVisibility : IValueConverter
|
|
{
|
|
public Visibility TrueValue { get; set; }
|
|
public Visibility FalseValue { get; set; }
|
|
|
|
public BoolToVisibility()
|
|
{
|
|
// set defaults
|
|
TrueValue = Visibility.Visible;
|
|
FalseValue = Visibility.Collapsed;
|
|
}
|
|
|
|
#region IValueConverter Members
|
|
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
if (!(value is bool))
|
|
return null;
|
|
return (bool)value ? TrueValue : FalseValue;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
{
|
|
if (Equals(value, TrueValue))
|
|
return true;
|
|
if (Equals(value, FalseValue))
|
|
return false;
|
|
return null;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |