Hi,
I have defined DataTemplate in code behind as below
StringBuilder
CellTemp2 = new StringBuilder();
CellTemp2.Append(
"<DataTemplate ");
"xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
"xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> ");
"<Grid>");
" <TextBlock x:Name=\"txtID\" HorizontalAlignment=\"Left\" />");
" </Grid>");
" </DataTemplate>");
e.ColumnLayout.Columns.Add(
new TemplateColumn()
{
HeaderText =
"",
Key =
"ID",
Width =
ColumnWidth.Auto,
MinimumWidth = 40,
MaximumWidth = 40,
IsSortable =
false,
IsResizable =
true,
IsGroupable =
ItemTemplate = (
DataTemplate)XamlReader.Load(CellTemp2.ToString())
});
I want to display serial numbers in first column.
In Initialize_Row event how can i find textblock control and display row numbers for that.
Please give solution.
Thanks,
Nandu
Hi Nandu,
You could use the CellControlAttached event, and look at the Cell.Control.Content
However, you need to be careful with this, as the controls for Cells are reused for recycling.
-SteveZ
Yes i can do as u said.....but i want to know is there any way to find textblock in code behind..
And how can i find that control
If "Serial Numbers" is a property in your data, then you should just bind it directly to the TextBlock.
If it's a Calculated Value from your data, you can bind do the Row's Data and use a converter to do the calculation.
Hope this helps,