Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须强制回答是/否。项目所有者想要一个“复选框”,其中包含一些丑陋的三态复选框或两个单选按钮。后者似乎是最整洁的,但我不知道如何制作它,以便只检查一个复选框。我唯一的另一个想法是填充复选框并使用下拉菜单。
采用
[Required] public bool? YesNo { get; set; }
在 ViewModel 中并确保它最初为空。
Bool 默认为 false。通过使用 nullable bool?,您将其初始状态设置为 null。