0

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.

melmi
  • 988
  • 3
  • 9
  • 27

1 Answers1

0

Maybe I'm missing something here.
If you have datagridcellinfo for a cell.

myDataGrid.Items.IndexOf(datagridcellinfo.Item)
Andy
  • 11,864
  • 2
  • 17
  • 20