Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing image in bool-type column when using AutoGenerateColumn (WPF)
    text
    copied!<p>I have </p> <pre><code>if (e.PropertyType == typeof(bool)) { e.Column.Header = "Status"; DataGridTemplateColumn templateColumn = new DataGridTemplateColumn(); templateColumn.Header = "Status"; DataTemplate imageTemplate = new DataTemplate(); DataTrigger imageBoolTrigger = new DataTrigger(); Converter.BoolToImage boolToImage = new Converter.BoolToImage(); Uri trueImageURI = new Uri(@"pack://application:,,,/MonitorView_wpf;component/Images/Icons/check-mark-16.png", UriKind.RelativeOrAbsolute); boolToImage.TrueImage.Source = new BitmapImage(trueImageURI); imageBoolTrigger.Binding = new Binding { Converter = boolToImage, ConverterParameter = e.Column }; imageTemplate.Triggers.Add(imageBoolTrigger); templateColumn.CellTemplate = imageTemplate; e.Column = templateColumn; } </code></pre> <p>but alas, its not working.</p> <p>how do I use an image instead of the autogenerated checkbox?</p> <p>my converter looks like this:</p> <pre><code> 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(); } } </code></pre> <p>my image does exist in the assemby, it's a png - ive tried all sorts of things, but never working.</p> <p>thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload