The following xaml code binds the “Image” with the datagrid template column.
<DataGridTemplateColumn Header="">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=Image}" Height="16" Width="16" VerticalAlignment="Top" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
The same thing need to be done in codebehind (c# code)
DataGridTemplateColumn im = new DataGridTemplateColumn();
im.Header = "";
Binding items1 = new Binding();
this is what i have Tried…. how to bind the datagridtemplate column to a image ??
Here is the code to add a DataGridTemplateColumn programatically.
http://social.msdn.microsoft.com/Forums/en/wpf/thread/df77a277-91d4-41f1-a42a-0fa02a443ff4
I have also added the source code of the sample app that I created. Hope it helps.
MainWindow.xaml file
MainWindow.xaml.cs file
SampleClass.cs file