You could use an eventhandler in the row of the grid OR you could read the value of the datagrid.selectedrow (the datagrid is the sender object):
int rownr = ((DataGrid)sender).SelectedIndex;