BitmapImage im = new BitmapImage();
string path1 = @"C:\abc.png";
im.UriSource=new Uri(path1);
DataGridTemplateColumn one = new DataGridTemplateColumn();
this.dataGrid1.Columns.Add(one);
Now i have to add the BitmapImage im in the datagridTemplateColumn.
How to add Image in the column??
Working with control templates in code is hard. In WPF the standard and effective way is to create your template layout in XAML. And then if you need to pass any data to your controls you use Data Binding. You shouldn't normally need to construct templates in code except for rare circumstances.
To get the same effect you intended above using XAML you write:
If the image path has to be dynamic for every grid row you can modify it like this:
and here's an example code behind for populating the grid with some data: