A lot of information on DataGridView , but I did not find information on DataGrid . How to handle a click on a row in a datagrid?

  • one
    Do DataGrid carriage and a small cart , which one interests you? - Bulson
  • I have seen the events, but click on the line in the grid is of interest .. - Nikolay

1 answer 1

Taken from here

You can use ItemContainerStyle

 <DataGrid ... > <DataGrid.ItemContainerStyle> <Style TargetType="DataGridRow"> <EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/> </Style> </DataGrid.ItemContainerStyle> ... </DataGrid> 

Handler:

 private void Row_DoubleClick(object sender, MouseButtonEventArgs e) { // execute some code } 
  • just add among the columns in wpf and when you click on the line can we read? - Nikolay
  • @Nikolay yes, but why not switch to using a DataGridView? - Yurii Manziuk
  • I just think that technology should not be scary, it should be studied. Yes, and I would not like to use Windows.Forms - Nikolay