lundi 20 juin 2016

How to perform action when CheckBox list view item is selected?

I have a Xamarin.Forms project where I am using Xlabs to implement checkboxes. I can get them to appear which is great. I want to be able to do this:

void OnSelection(object sender, SelectedItemChangedEventArgs e)
    {
        if (e.SelectedItem == null)
            return;
        var selectedStudent = ((ListView)sender).SelectedItem as Student;

        // set time of student checkin
    }

But with my check boxes. I want to be able to handle checkbox selection as it happens. From what I've seen online I can set a new boolean property of my student object selected, but that simply doesn't work with my project. Here is my current approach:

    void OnSelection(object sender, EventArgs e)
    {
        CheckBox isCheckedOrNot = (CheckBox)sender;
        var name = isCheckedOrNot.DefaultText;

        //not sure what to do here?
        var student = ((CheckBox)sender)...

        // set time of student checkin
    }




Aucun commentaire:

Enregistrer un commentaire