I have RadGridView to which I am dynamically adding bound data columns. I can successfully add columns as necessary, however, when I try to define a column with a CellTemplateSelector specified the selected CellTemplate is not applied to the column. Through debugging the CellTemplateSelector I know that it is getting called and resolving the correct CellTemplate when the column is added, and the template applies correctly if used in the RadGridView XAML layout. The pertinent code related to adding the column is as follows:
and the template is:
I have tried rebinding the grid, and calling ApplyTemplate() on both the grid, after adding the column, and on the cell passed to DataTemplateSelector.SelectTemplate() to no avail. Am i missing something? How can I get the template to be applied to the column.
GridViewColumnCollection columns =
this
.gridView.Columns;
...elided...
var col = (
new
GridViewDataColumn()
{
DataMemberBinding =
new
Binding(menuItem.BindingPath),
Header = menuItem.Caption,
CellTemplateSelector =
new
MemberCellTemplateSelector(),
});
columns.Add(col);
and the template is:
<
local:MemberCellTemplateSelector.PhoneNumberList
>
<
DataTemplate
>
<
ItemsControl
ItemsSource
=
"{Binding MemberPhoneNumber}"
>
<
ItemsControl.ItemsPanel
>
<
ItemsPanelTemplate
>
<
StackPanel
Orientation
=
"Vertical"
/>
</
ItemsPanelTemplate
>
</
ItemsControl.ItemsPanel
>
<
ItemsControl.ItemTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
HorizontalAlignment
=
"Right"
>
<
TextBlock
Text
=
"{Binding PhoneNumber}"
/>
<
TextBlock
Text
=
"{Binding PhoneNumberTypeKey, StringFormat='({0})'}"
/>
</
StackPanel
>
</
DataTemplate
>
</
ItemsControl.ItemTemplate
>
</
ItemsControl
>
</
DataTemplate
>
</
local:MemberCellTemplateSelector.PhoneNumberList
>
I have tried rebinding the grid, and calling ApplyTemplate() on both the grid, after adding the column, and on the cell passed to DataTemplateSelector.SelectTemplate() to no avail. Am i missing something? How can I get the template to be applied to the column.