Reputation:
Need to do some logic based on the current row selected. New to WPF before I would do something like this;
int i myDataGridView.CurrentCell.RowIndex
Now that is not available, what is best way to get selected row?
Upvotes: 2
Views: 6880
Reputation: 18578
Use DataGrid.SelectedItem
property. It gives the Selected Item on the DataGrid if SelectionMode
is Single
. Else DataGrid.SelectedItems
gives the multiple selection if SelectionMode is Extended
or Multiple
Upvotes: 1
Reputation: 1356
Try this:
SomeObject someObject = (SomeObject)myDataGridView.SelectedItem
Upvotes: 0