How to fill the row header with a auto-increasing number?

Sep 17, 2008 at 10:35 AM
In the DataGridCTPSample, the row header is bind with the 'Id'.
If I want to fill the row header with a auto-increasing number just like that in excel, how can I get it?
thanks a lot!
Sep 17, 2008 at 1:21 PM
Are you talking about the DataGridCTPSample from  If so, that should be an example of how to do an auto-incrementing Id.
Sep 18, 2008 at 3:37 AM
yes, I am talking about that DataGridCTPSample.
In that example, the row header is bind with the 'Id', when the user resort the rows by other columns, the numbers in row header will be disordered.
I don't want that. I want the row header number always be in order just like that in excel.
Can I get it? Thx!
Sep 19, 2008 at 5:00 AM
So it looks that you don't want the numbers in the row header to really be associated with each data item but more associated with the DataGrid itself.  If you can wait till the full release there will be a LoadingRow event that you can attach to.  In the event you can set the header each time to the number you want based on the item in the event args.  If you can't wait, another option is to override the DataGrid.PrepareContainerForItemOverride and set the header in the same way described above after calling base.PrepareContainerForItemOverride.