WPF Checkbox check IsChecked

后端 未结 8 828
别跟我提以往
别跟我提以往 2020-12-08 10:25

I\'m not talking about an event handler for this, but rather a simple If Statement checking if the CheckBox has been checked. So far I have:

<
8条回答
  •  北海茫月
    2020-12-08 10:42

    You can use null coalescing operator. This operator returns right-hand operand if the left-hand operand is null. So you can return false when the CheckBox is in indeterminate state (when the value of IsChecked property is set to null):

    if (chkRevLoop.IsChecked ?? false)
    {
    
    }
    

提交回复
热议问题