37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
|
|
using System.Globalization;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Data;
|
|||
|
|
using System;
|
|||
|
|
|
|||
|
|
namespace WpfAppTest.Converter
|
|||
|
|
{
|
|||
|
|
public class NullableToVisibilityConverter : IValueConverter
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// The visibility value if the argument is null.
|
|||
|
|
/// </summary>
|
|||
|
|
public Visibility NullValue { get; set; }
|
|||
|
|
|
|||
|
|
public Visibility NotNullValue { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Creates a new <see cref="NotNullToVisibilityConverter" />.
|
|||
|
|
/// </summary>
|
|||
|
|
public NullableToVisibilityConverter()
|
|||
|
|
{
|
|||
|
|
NullValue = Visibility.Collapsed;
|
|||
|
|
NotNullValue = Visibility.Visible;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
return value == null ? NullValue : NotNullValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
return Binding.DoNothing;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|