So I am not quite familiar with WPF yet and in WinForms, you can have CellDoubleClick event which I can get the value like
Private Sub DataGridView1_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
If e.RowIndex >= 0 Then
Dim row As New DataGridViewRow
row = Me.DataGridView1.Rows(e.RowIndex)
THE_ID = row.Cells("ID").Value.ToString() 'The ID is saved
In WPF data grids, the grid itself should never be used to acquire data. But instead, use the information you DO know about the grid. The selected row index, or "SelectedIndex" is what you should use to cross-reference your bound data source.
For example, let's assume that you had some DataTable and bound it's view to the DataGrid, you might have something that looks like this:
Dim View As DataView = TryCast(DataGrid1.ItemsSource, DataView) If View IsNot Nothing Then Dim ViewRow As DataRowView = View.Item(DataGrid1.SelectedIndex) Dim ColumnValue As Object = ViewRow.Item("ID") 'or ViewRow.Item(0) for positional value. 'do something with ColumnValue here. End If
That should work in the event that you are binding a DataTable's view to the grid, but remember the grid can take any IEnumerable. So your question really depends heavily on what object is your ItemsSource, and how that object implements IEnumerable.
hope that helps!