Search This Blog

Friday, June 3, 2016

DataGrid WPF show row number

WPF > Controls > ItemsControl > DataGrid > Show row number

XAML


<DataGrid 
        x:Name="dataGrid"
        LoadingRow="dataGrid_LoadingRow"

Code

private void dataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
  // show row number
    e.Row.Header = (e.Row.GetIndex() + 1).ToString();

}