将true / false更改为图像

我在数据网格中有一个内容为True / false的列,如何根据文本将此true / false(boolean)更改为图像?

我正在使用c#wpf。

编辑:

            

使用DataGridTemplateColumn为包含Image的列提供DataTemplate,并使用值转换器或数据触发器根据列的值设置图像源。 以下是使用数据触发器的示例:

             
 public class BoolToImage : IValueConverter { public Image TrueImage { get; set; } public Image FalseImage { get; set; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (!(value is bool)) { return null; } bool b = (bool)value; if (b) { return this.TrueImage; } else { return this.FalseImage; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } 

然后在您的xaml中,作为资源:

  

然后在你的绑定:

ImageSource={Binding Path=BoolProp,Converter={StaticResource BoolImageConverter}}"