开发者

Why is CheckBox.IsChecked property Nullable<bool>?

Why is the IsChecked property of a checkbox control in WP开发者_运维技巧F 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.

Why is CheckBox.IsChecked property Nullable<bool>?


According to the documentation, the IsChecked property has three different possible states:

 

Why is CheckBox.IsChecked property Nullable<bool>?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜