为什么CheckBox.IsChecked属性为Nullable< bool&gt ;?

编程入门 行业动态 更新时间:2024-10-24 12:31:35
本文介绍了为什么CheckBox.IsChecked属性为Nullable< bool&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这看起来像一个有趣的问题 -

为什么是复选框控件的 IsChecked WPF的类型 bool?(或 Nullable< bool> ),我的意思是如何一个复选框控件的值'null'? /library/system.windows.controls.primitives.togglebutton.ischecked.aspxrel =nofollow noreferrer>文档, IsChecked 属性有三种不同的可能状态:

因此,当 IsChecked 设置为 null 时,将显示不确定状态。这通常表示为阴影或灰色的控件。

This seems to me like a funny question -

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' ?

解决方案

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.

更多推荐

为什么CheckBox.IsChecked属性为Nullable&lt; bool&gt ;?

本文发布于:2023-11-11 06:56:20,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   Nullable   CheckBox   IsChecked   bool

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!