mardi 18 mai 2021

Problem with checkbox Ischecked in a click event

I have a problem with checkbox. I'm trying to explain. My Datagrid can have multiple row, so multiple checkbox.

When one or many checkbox is true, so a button IsEnable=true. But if no checkbox is true, so the button is disable.

Maybe an issue with a count of checkbox is check ? Or maybe the click processus is not appropriate ?

Here my code :

        private void Chk_UID_IsSelected_Click(object sender, RoutedEventArgs e)
    {
        var Chkbox = sender as CheckBox;

        if (Chkbox.IsChecked == true)
        {
            UID_Disconnect.IsEnabled = true;
        }
        else
        {
            UID_Disconnect.IsEnabled = false;
        }

But my code check only one checkbox in fact. If i click on 2 checkbox and uncheck one, my button have an incorrect state.

My design :

row with checkbox




Aucun commentaire:

Enregistrer un commentaire