2015-06-04 18:15:54 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
2015-07-06 12:01:48 +01:00
|
|
|
|
namespace Filtration.Common.Converters
|
2015-06-04 18:15:54 +01:00
|
|
|
|
{
|
2015-07-06 12:01:48 +01:00
|
|
|
|
public class BooleanVisibilityConverter : IValueConverter
|
2015-06-04 18:15:54 +01:00
|
|
|
|
{
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
{
|
2015-06-27 18:08:06 +01:00
|
|
|
|
if (value is bool && targetType == typeof (Visibility))
|
|
|
|
|
{
|
|
|
|
|
var val = (bool) value;
|
|
|
|
|
if (val)
|
|
|
|
|
{
|
|
|
|
|
return Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
if (parameter is Visibility)
|
|
|
|
|
{
|
|
|
|
|
return parameter;
|
|
|
|
|
}
|
|
|
|
|
return Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
if (value != null)
|
|
|
|
|
{
|
|
|
|
|
return Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (parameter is Visibility)
|
|
|
|
|
{
|
|
|
|
|
return parameter;
|
|
|
|
|
}
|
|
|
|
|
return Visibility.Collapsed;
|
2015-06-04 18:15:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|