Hi,
I'm using DataTemplateSelector with the WPFToolkit DataGrid. I want to select the editing template for one cell based on the value of another cell on the same row.
The DataTemplateSelector's SelectTemplate method takes two arguments: one is the data item displayed by the grid row, the other is the grid cell.
What I want to know is how to get the value of another cell from within the SelectTemplate method. However, I'm not sure of the correct way to get this information by accessing properties of the cell.
public class RangeValuesEditTemplateSelector : DataTemplateSelector
{
public DataTemplate NumberTemplate{get; set;}
public DataTemplate TextTemplate{get; set;}
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
//TODO: need to find the correct way to populate the if condition below
DataGridCell theCell = container as DataGridCell;
if (theCell.something.somethingElse)
{
return NumberTemplate;
}else{
return TextTemplate;
}
}
}
Can anyone help?
Many thanks in advance.
AT