using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; //---------------------------------------------------------------- //Module Name: $safeprojectname$ //Purpose: //CopyRight: Muchinfo //History: //---------------------------------------------------------------- //DateTime 2016/3/28 9:55:34 //Author //Description Create //---------------------------------------------------------------- namespace Muchinfo.MTPClient.Infrastructure.Converters { public class EnumBooleanConvert : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value!=null&¶meter!=null&&(int)value==int.Parse(parameter.ToString()) ) ////值相等的 { return true; } return false; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value.Equals(true)) { var result= Enum.Parse(targetType, parameter.ToString()); return result; } else { ////设置值时不进行赋值 var result = Enum.Parse(targetType, "-1"); return result; } } } }