码迷,mamicode.com
首页 > Windows程序 > 详细

wpf转换器

时间:2016-04-07 20:43:54      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:

方面进行转换绑定

 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 }

 

wpf转换器

标签:

原文地址:http://www.cnblogs.com/billly/p/5365012.html

(1)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!