WPF/VB如何将三态复选框(或可空布尔值)设置为Nothing(空)

WPF/VB如何将三态复选框(或可空布尔值)设置为Nothing(空),wpf,vb.net,checkbox,nothing,threestate,Wpf,Vb.net,Checkbox,Nothing,Threestate,标题解释了一切。对于VB,关键字Nothing与False相同 此代码验证复选框是否为三状态复选框,并设置默认值,indexterminateif是“三状态”,如果不是,则设置为false myThreeStateChkbox.IsChecked = If(myThreeStateChkbox.IsThreeState, Nothing, False) 结果相同,总是False。如何设置不确定状态?如何设置新的可空(布尔值) 或者更短,只需新建布尔值?: myThreeStateChkbox.

标题解释了一切。对于VB,关键字
Nothing
False
相同

此代码验证复选框是否为三状态复选框,并设置默认值,
indexterminate
if是“三状态”,如果不是,则设置为false

myThreeStateChkbox.IsChecked = If(myThreeStateChkbox.IsThreeState, Nothing, False)

结果相同,总是
False
。如何设置
不确定状态?

如何设置
新的可空(布尔值)

或者更短,只需
新建布尔值?

myThreeStateChkbox.IsChecked = If(myThreeStateChkbox.IsThreeState, New Boolean?, False)

对!它可以工作,同时我找到了另一个解决方案,我将它作为一个备选方案编写
myThreeStateChkbox.IsChecked=If(myThreeStateChkbox.isthrestate,DirectCast(Nothing,Boolean?),False)
myThreeStateChkbox.IsChecked = If(myThreeStateChkbox.IsThreeState, New Boolean?, False)