mercredi 4 janvier 2017

wpf get selected row when checkbox value changes

I'm building a wpf application in c#. I've got a GridView with information. Every row has a checkbox. When a checkbox is being clicked I would like to receive the row's user name value (in column 1).

Right now it's working but the entire row has to be selected. Otherwise I receive of course a null exception.

private void CheckBox_breakfast(object sender, RoutedEventArgs e)
{
    Reservation reservation = gridReservations.SelectedItem as Reservation;
    string name = reservation.user_name;
}

How do I get this to work with only selecting the checkbox instead of the entire row?

Already searched on the web and tried a lot but nothing works.

Would help me a lot!




Aucun commentaire:

Enregistrer un commentaire