| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2016/5/16 15:43:57
- //Author
- //Description Create
- //----------------------------------------------------------------
- using System.Windows;
- using System.Windows.Data;
- namespace Muchinfo.MTPClient.Infrastructure.Converters
- {
- public class EnumVisibilityConvert: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 Visibility.Visible;
- }
- return Visibility.Collapsed;
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- if (value.Equals(Visibility.Visible))
- {
- var result = Enum.Parse(targetType, parameter.ToString());
- return result;
- }
- else
- { ////设置值时不进行赋值
- var result = Enum.Parse(targetType, "-1");
- return result;
- }
- }
- }
- }
|