| 12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Data;
- namespace Muchinfo.MTPClient.Infrastructure.Converters
- {
- public class ExEnumBooleanConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- if (value != null && parameter != 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;
- }
- }
- }
- }
|