Little rusty here. I'm trying to display a image in a WPF Gridview. Below is the XAML for the template column. The converter is also below, which is calling and finding the image and returning the correct BitmapImage. The image data loads and the column scales to size but the image is not displayed. What is it I'm missing...
<DataGridTemplateColumn Header="JIRA ICON CONVERTER" Width="SizeToCells" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding TaskType, Converter={StaticResource IconConverter}}" Stretch="None"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Converter
<Window.Resources>
<local:EnumToIconConverter x:Key="IconConverter"/>
</Window.Resources>
public class EnumToIconConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
switch ((JiraType)value)
{
case JiraType.Task:
return new BitmapImage(new Uri("TaskIcon.png", UriKind.Relative));
case JiraType.Story:
return new BitmapImage(new Uri("StoryIcon.png", UriKind.Relative));
default:
return new BitmapImage(new Uri("StoryIcon.png", UriKind.Relative));
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}