zoukankan      html  css  js  c++  java
  • wpf datagrid field to image converter 字段 图片转化器

    
    
    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     }
  • 相关阅读:
    PE感染学习
    寻找复活节彩蛋egg huting 学习
    unicode exp学习
    zlib的安装与使用
    PDF 学习
    MW6MaxiCode ACX溢出
    Blog 迁移啦
    Malloc Maleficarum复盘
    [winafl]这几天的折腾
    [pwnable.kr]--alloca
  • 原文地址:https://www.cnblogs.com/Fred1987/p/11547920.html
Copyright © 2011-2022 走看看