Powershell Item checkbox Value

Tomáš Jartymyk 1 Reputation point
2022-02-17T15:28:09.887+00:00

Hello, Today i try set checkbox XAML for powershell, but when i created xaml and put this checkbox on formular, alway value is False. I created this function. When i click button without checkbutton and value is false, when i click on checkbutton and click button valu is still false.

function truornot {
if($check.Checked){
Write-host "Is true"
}else{
Write-host "Is False"
}
}

$button.Add_Click({
truornot
})

But when i show value $check and value is System.Windows.Controls.CheckBox Obsah:CheckBox IsChecked:False and when i click on checkbox value is System.Windows.Controls.CheckBox Obsah:CheckBox IsChecked:True

I dont understand why value $check.checked is still false. I try set $check.checked -eq $true

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,504 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.