using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;
namespace ShrlAlgoToolkit.Mvvm.Converters
{
///
/// Converts null or not null to a .
///
public class NotNullToVisibilityConverter : IValueConverter
{
///
/// The visibility value if the argument is null.
///
public Visibility NullValue { get; set; }
///
/// Creates a new .
///
public NotNullToVisibilityConverter()
{
NullValue = Visibility.Collapsed;
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null ? NullValue : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
}
}