I have a DataGrid
which is filled with a List of Objects.
It has a MouseDoubleClick
event.
I am trying to find out which row exactly of the DataGrid
was clicked.
So far I've tried this:
private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataGridRow Row = sender as DataGridRow;
int RowNumber = Row.GetIndex();
//dostuff with RowNumber ;
}
which sadly gets me a System.NullReferenceException
.
xaml for completeness:
<DataGrid x:Name="DataGrid_Table" Grid.Row="3" AutoGenerateColumns="True" ItemsSource="{Binding}" IsReadOnly="True"
MouseDoubleClick="DataGrid_MouseDoubleClick" FontSize="22" />