当前位置: 移动技术网 > IT编程>开发语言>.net > wpf datagrid field to image converter 字段 图片转化器

wpf datagrid field to image converter 字段 图片转化器

2019年09月19日  | 移动技术网IT编程  | 我要评论

洪燕华博客,黑暗圣经在线,icq中文版


1 <datagridtemplatecolumn header="binding">
2                             <datagridtemplatecolumn.celltemplate>
3                                 <datatemplate>
4                                     <image x:name="bindimg" height="30" width="30" source="{binding isbindable,converter={staticresource bindableconverter}}" verticalalignment="center" horizontalalignment="center"/>
5                                 </datatemplate>
6                             </datagridtemplatecolumn.celltemplate>                             
7                         </datagridtemplatecolumn>
 1 public class bindableconverter : ivalueconverter
 2     {
 3         public object convert(object value, type targettype, object parameter, cultureinfo culture)
 4         {
 5             bool isbind;
 6             if(value==null||string.isnullorwhitespace(value.tostring()))
 7             {
 8                 return "../../resource/images/unbinded.jpg";
 9             }
10             if (boolean.tryparse(value.tostring(), out isbind))
11             {
12                 if (isbind)
13                 {
14                     return "../../resource/images/binded.jpg";
15                 }
16                 else
17                 {
18                     return "../../resource/images/unbinded.jpg";
19                 }
20             }
21             return null;
22         }
23 
24         public object convertback(object value, type targettype, object parameter, cultureinfo culture)
25         {
26             throw new notimplementedexception();
27         }
28     }

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网