I like to be able to display row number on the row header. I was able to pull this off, but the numbers are not always display in right order when 1000 of row are loaded. (see the attached image) I put the blow code in RowLoaded event of the grid.
Please advice if there is any sophisticated way to do this.
var border = gridViewRow.ChildrenOfType<Border>() .Where(b => b.Name == "PART_IndicatorPresenter") .FirstOrDefault();
if (border != null)
var innerBorder = border.Child as Border;
if (innerBorder != null && !(innerBorder.Child is TextBlock))
var textBlock = new TextBlock();
textBlock.TextAlignment = TextAlignment.Center;
textBlock.VerticalAlignment = VerticalAlignment.Center;
textBlock.Text = (_target.Items.IndexOf(gridViewRow.Item) + 1).ToString();
innerBorder.Child = textBlock;