方面进行转换绑定
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Windows.Data; 6 7 namespace NetReform 8 { 9 [ValueConversion(typeof(string), typeof(string))] 10 class ReadBtnBKConvert : IValueConverter 11 { 12 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 13 { 14 string b = "000"; 15 16 string reValue = System.Convert.ToString(value); 17 if (reValue == "green") 18 { 19 b = "0"; 20 } 21 else if (reValue == "yellow") 22 { 23 b = "1"; 24 } 25 else if (reValue == "") 26 { 27 b = ""; 28 } 29 else 30 { 31 b = "1";//其它为1 32 } 33 return b; 34 } 35 36 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 37 { 38 throw new NotImplementedException(); 39 } 40 } 41 }
时间: 2024-11-04 16:51:45