定义模板列:
<sdk:DataGrid>
<sdk:DataGrid.Columns>
<sdk:DataGridTemplateColumn Header="xxx" Width="Auto" IsReadOnly="True">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock FontSize="11" VerticalAlignment="Center" Margin="4,0,0,0"></TextBlock>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
在DataGrid的LoadingRow事件中自定义显示数据
private void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e)
{
int idx = e.Row.GetIndex();
TextBlock cell = dataGrid1.Columns[0].GetCellContent(e.Row) as TextBlock;
// 比如:行号。
cell.Text = (idx+1).ToString();
}