I've done some looking around, and it seems there is no apparent means of telling a WPF DataGrid
which property in the item bound to a DataRow
, and nor is there a special field on the DataRow
for this property. Using a special 'Key' column that is normally hidden is hideously clumsy, and adding such a property to the grid somehow is a no-fun endeavour. I'm not being unreasonable here - most other grids have such functionality.
You should not need it. Using databinding you bind a collection of Objects to the DataGrid. Usually you handle directly the underlying collection.
Ie if you need the ID of the 5th row just get the 5th element in the underlying collection and extract the ID.
Also you can cast SelectedItem to your collection item.