Why is IsChecked property nullable boolean in WPF CheckBox?

前端 未结 4 1833
囚心锁ツ
囚心锁ツ 2020-12-11 14:36

Is there a case when IsChecked property on WPF CheckBox null ?

I guess that will answer my question from title of question.

相关标签:
4条回答
  • 2020-12-11 15:08

    It is null when you don't know if its checked or not: http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.togglebutton.ischecked.aspx

    In many systems a checkbox like this is shaded instead of being checked.

    0 讨论(0)
  • 2020-12-11 15:20

    Null means the CheckBox is indeterminate (is neither blank nor checked, instead it either has a line through it, or the box has a gray box inside it)

    0 讨论(0)
  • 2020-12-11 15:31

    If that is the case then it's probably a three-state-checkbox, have a look at http://msdn.microsoft.com/en-us/library/system.windows.forms.checkbox.threestate.aspx for an explaination.

    0 讨论(0)
  • 2020-12-11 15:32

    If we want to bind a value from DB and if that value is null then we have to handle that also. A boolean DB value can be True, False or NULL. So the UI checkbox also must be handle the there states. That's why WPF CheckBox has three state.

    0 讨论(0)
提交回复
热议问题