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     }
  • 相关阅读:
    B. Pasha and Phone
    GCD(关于容斥原理)
    二分乘法
    Lucky7(容斥原理)
    E. Devu and Flowers
    最大公约数最小公倍数
    leetcode每日刷题计划--day55
    Titanic--kaggle竞赛入门-生存预测
    做题记录--day54
    机器学习上机作业1记录 && 相关知识点复习
  • 原文地址:https://www.cnblogs.com/Fred1987/p/11547920.html
Copyright © 2011-2022 走看看