You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.0 KiB
41 lines
1.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Data;
|
|
|
|
namespace ValueConverterSample.Converter
|
|
{
|
|
internal class YesNoToBoolConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value == null)
|
|
return false;
|
|
|
|
switch (value.ToString().ToUpper())
|
|
{
|
|
case "YES":
|
|
return true;
|
|
case "NO":
|
|
return false;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (!(value is bool))
|
|
return "NO";
|
|
|
|
bool converted = (bool)value;
|
|
if (converted)
|
|
return "YES";
|
|
else
|
|
return "NO";
|
|
}
|
|
}
|
|
}
|
|
|