//创建DataGridTemplateColumn
var column= new DataGridTemplateColumn();
column.CanUserResize = false;
column.CanUserReorder = false;
column.Header = "";
//创建FrameworkElementFactory
var img= new FrameworkElementFactory(typeof(Image));
//创建绑定
Binding binding= new Binding("Judgement.TotalJudgement");
//设置转换器
binding.Converter = new JudgementToImageConverter();
img.SetBinding(Image.SourceProperty, binding);
//创建数据模板
var template = new DataTemplate();
template.VisualTree = img;
column.CellTemplate = template;
grid.Columns.Add(column);