33 lines
934 B
C#
33 lines
934 B
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace CtrEditor.Converters
|
|
{
|
|
public class BooleanToLocalizedTextConverter : IValueConverter
|
|
{
|
|
public string TrueText { get; set; } = "True";
|
|
public string FalseText { get; set; } = "False";
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is bool boolValue)
|
|
{
|
|
return boolValue ? TrueText : FalseText;
|
|
}
|
|
return FalseText;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is string text)
|
|
{
|
|
if (text == TrueText)
|
|
return true;
|
|
if (text == FalseText)
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
} |