I am attempting to set a column's cell template in code to a template that is also generated in code, but its not working as I assumed it would.
The template seems to only be applied to one row at a time, always the last row to draw. I suspect this is because its an instance of a template and not a resource, but I'm not sure the right way to set this up.
I am making a custom search control that displays results in a grid; I need to add a button to a column and hook the click event up. It is much easier for me to set up in code in this case.
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
//find grid column control part
GridViewColumn PART_SelectColumn = GetTemplateChild("PART_SelectColumn") as Telerik.Windows.Controls.GridViewColumn;
//make cell content
RadButton btn_SelectItem = new RadButton() { Content = "Add"};
btn_SelectItem .Click += PART_SelectItem_Click;
//generate template - code builds a sealed datatemplate with the button as the content
DataTemplate SelectTemplate = DataTemplateExtentions.CreateDataTemplate ( () => { return btn_SelectItem } );
//Set the column's cell template - I suspect this is what I'm doing wrong
PART_SelectColumn.CellTemplate = SelectTemplate;
}
see attached image; the template only applies to the last row.
Anyone know where I'm going wrong?