Why is the IsChecked
property of a checkbox control in WPF of type bool?
(or Nullable<bool>
). I mean how can a checkbox control have the value of null
?
Yes the null value exists and appears as a filled box. It indicates "Not Applicable" to the system.
According to the documentation, the IsChecked
property has three different possible states:
So, when IsChecked
is set to null
, the check box will show an "indeterminate" state. This is commonly represented as a shaded, or greyed-out, control.
Checkboxes can have a 3rd, grayed, indeterminate state.
Don't forget to set the checkbox's property IsThreeState to true to enable this functionality.
Because WPF supports binding. If we bind a DB boolean column value to a checkbox. That column may have True/False/Null values. That means it has three values for a boolean field. So the WPF UI also should handle the three state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With