32 lines
855 B
C#
32 lines
855 B
C#
using System;
|
|
using System.Windows.Data;
|
|
using System.Globalization;
|
|
|
|
namespace XLIMS.MVVM.Converters
|
|
{
|
|
[ValueConversion(typeof(Boolean), typeof(String))]
|
|
public class BoolConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
try
|
|
{
|
|
Boolean data = (Boolean)value;
|
|
return data;
|
|
}
|
|
catch { return value; }
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
string strValue = value.ToString();
|
|
Boolean resultData;
|
|
if (Boolean.TryParse(strValue, out resultData))
|
|
{
|
|
return resultData;
|
|
}
|
|
return value;
|
|
}
|
|
}
|
|
}
|