I am using the following code to dynamically load columns in a Silverlight datagrid and would prefer to use the Telerik Grid. My first problem is trying to figure out what the equivalent of the DataGridTemplatolumn is with the GridView.
Can anyone help with how to dynamically create columns or help with converting the following code to the Telerik GridView?
private DataGridTemplateColumn CreateTemplateColumn(int i, string propNumber, string propName)
{
DataGridTemplateColumn column = new DataGridTemplateColumn();
column.Header = String.Format("{1}", i, propName);
column.CellTemplate = (DataTemplate)XamlReader.Load(CreateColumnTemplate(i, "AllocationUnits"));
return column;
}
private string CreateColumnTemplate(int index, string propertyName)
{
StringBuilder CellTemp = new StringBuilder();
CellTemp.Append("<
DataTemplate
");
CellTemp.Append("
xmlns
=
'http://schemas.microsoft.com/winfx/2006/xaml/presentation'
");
CellTemp.Append("
xmlns:x
=
'http://schemas.microsoft.com/winfx/2006/xaml'
>");
CellTemp.Append(String.Format("<
TextBlock
Text
=
'{{Binding ItemCustomers[{0}].{1}}}'
/>", index, propertyName));
CellTemp.Append("</
DataTemplate
>");
return CellTemp.ToString();
}