mercredi 29 septembre 2021

Powershell and XAML checkboxes problem while executing

I made a XAML form from visual studio 2012, the XAML form have checkboxes that you select to get the information.

Every checkbox have a powershell function behind.

When executing the form, if I select one checkbox and unselect it, when I press the button to execute the function, even if the checkbox is unchecked at the moment I press the execution button its continuing thinking that the checkbox is selected. But I unchecked the checkbox before clicking the execution button. So it's continuing executing other functions that I don't want it to execute.

Do we have a kind of code that force PowerShell to think the checkbox is $false while the form is in execution ?

Here an example of code:

 $apps_checkbox = $Window.FindName("apps_checkbox")
    $apps_checkbox.Add_Click({ 
    if($apps_checkbox.isChecked -eq $true){
       $retrievebutton.add_click({
       IF(!(GCI ".\$FOLDERNAME\$COMP" | WHERE-OBJECT NAME -EQ "APPS")){ 
        NEW-ITEM -ITEMTYPE DIRECTORY -NAME APPS -PATH ".\$FOLDERNAME\$COMP" 
       }
       NEW-ITEM -ITEMTYPE FILE -PATH 
       ".\$FOLDERNAME\$COMP\APPS\APPS-$COMP.TXT" 
       LIST-APPS 
        }) 
       } 
      })



Aucun commentaire:

Enregistrer un commentaire