43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace BeWo.Converter
|
|
{
|
|
public class ObjectBoolConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
bool lFalseIfNull = true;
|
|
|
|
if (parameter != null || parameter is string)
|
|
{
|
|
bool.TryParse((string)parameter, out lFalseIfNull);
|
|
}
|
|
|
|
if (value is string)
|
|
{
|
|
if (lFalseIfNull)
|
|
{
|
|
return !string.IsNullOrEmpty((string)value);
|
|
}
|
|
else
|
|
{
|
|
return string.IsNullOrEmpty((string)value);
|
|
}
|
|
}
|
|
|
|
if (lFalseIfNull)
|
|
{
|
|
return value != null;
|
|
}
|
|
|
|
return value == null;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
} |