Question

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

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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)

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top