There are zillions of questions all over the web, including StackOverflow
(WPF DataGrid: How to Determine the Current Row Index? and WPF Datagrid cell, cellinfo and selectedcells + custom selection for example) on this topic. My problem with answers to those questions is that they need a linear search in items which is not efficient.
I noticed that DataGridCellInfo
has an internal
property named ItemInfo
which in turn has a property named Index
. This Index
is exactly what I am looking for. Why is this property designed to be not public
? How is the correct way of accessing it?
Please note that I want to work with SelectionUnit="Cell"
and thus SelectedIndex
always is equal to -1
.