wpf转换器
方面进行转换绑定
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 }
作者:Ants_double
出处:https://www.cnblogs.com/ants_double/
本文版权归作者和博客园所有,欢迎转载。转载请在留言板处留言给我,且在文章标明原文链接,谢谢!
如果您觉得本篇博文对您有所收获,觉得我还算用心,请点击右下角的 [大拇指],谢谢!