Http://www.cnblogs.com/chenlhuaf/archive/2009/02/11/1388426.html
Gridviewcolumn column = new gridviewcolumn ();
Gridviewcolumnheader H = new gridviewcolumnheader ();
H. content = "?????? ";
H. Tag = "*******";
Column. header = h;
Datatemplate dt = new datatemplate ();
Frameworkelementfactory FEF = new frameworkelementfactory (typeof (checkbox ));
Binding binding = new binding ();
Binding. Path = new propertypath ("marketindicator ");
FEF. setbinding (checkbox. contentproperty, binding );
FEF. setvalue (checkbox. foregroundproperty, brushes. White );
DT. visualtree = FEF;
Column. celltemplate = DT;
(This. lvexecutiontable. view as gridview). Columns. Add (column );
Http://hi.baidu.com/icexile/blog/item/2e75a73d47171108bba167e2.html
// a XAML is dynamically generated in the memory, describing a datatemplate
xnamespace NS = "http://schemas.microsoft.com/winfx/2006/xaml/presentation ";
xelement xdatatemplate =
New xelement (NS + "datatemplate", new xattribute ("xmlns", "http://schemas.microsoft.com/winfx/2006/xaml/presentation "),
New xelement (NS + "textblock",
New xelement (NS + "textblock", new xattribute ("width", "100 "), new xattribute ("text", "{binding Path = Name}"),
New xelement (NS + "textblock", new xattribute ("width ", "100"), new xattribute ("text", "{binding Path = Nick}")
);
// instantiate the in-memory XAML into a datatemplate object and assign it to the
// itemtemplate attribute of ListBox to complete data binding
xmlreader xr = xdatatemplate. createreader ();
datatemplate = xamlreader. load (xr) as datatemplate;
lstbox _. itemtemplate = datatemplate;
// bind the textbox to the name and Nick attributes of the current item respectively.
txtboxname _. setbinding (textbox. textproperty, "name");
txtboxnick _. setbinding (textbox. textproperty, "Nick");
}