I added a read only [NotMapped] property to my Customer entity(am using Entity Framework 4) which returned a boolean and then bound an Image inside DataGridTemplateColumn to this and set the source using a value converter:
Entity
[NotMapped]
public bool ShowWarning
{
get
{
if (this.AuditableNotes != null && this.AuditableNotes.Count(an => an.Warning) > 0)
{
return true;
}
else
{
return false;
}
}
}
XAML
<DataGridTemplateColumn
Header="Status">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image x:Name="MyImage" Source="{Binding ShowWarning, Converter={StaticResource notesStatusConverter}}" Width="25" Height="20"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
ValueConverter
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value != null && (bool)value == true)
{
return "/Assets/Images/symbol_error.png";
}
else
{
return "/Assets/Images/symbol_information.png";
}
}