I\'ve to pivot information data from a query, and show images based on value read from the underlying database.
Let\'s say I have this data out of my query:
You could handle the AutoGeneratingColumn
event and programmatically create a DataGridTemplateColumn
that contains an Image
element. Try this:
private void OnAutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
if (e.PropertyName != "Identifiant" && e.PropertyName != "=>")
{
FrameworkElementFactory image = new FrameworkElementFactory(typeof(Image));
image.SetBinding(Image.SourceProperty, new Binding(e.PropertyName));
e.Column = new DataGridTemplateColumn
{
CellTemplate = new DataTemplate() { VisualTree = image },
Header = e.PropertyName
};
}
}