每个模型属性的C#复选框
|
我不确定是否可以通过简单的方式实现(只需编写少量代码即可)。
我有一个模型:
public static Class TestClass
{
public static bool Test1 { get; set; }
public static bool Test2 { get; set; }
public static bool Test3 { get; set; }
public static bool Test4 { get; set; }
public static bool Test5 { get; set; }
public static bool Test6 { get; set; }
}
一个简单的Foreach或其他命令能否创建6个复选框,每个复选框命名为属性名称并选中绑定到实际属性?
所以基本上我想为每个属性创建一个:
var check = new CheckBox { Name = Test1 };
check.CheckedChanged += (s,ea) => { TestClass.Test1 = check.IsChecked; };
但是对于每个属性,甚至可能用更少的代码?
没有找到相关结果
已邀请:
2 个回复
舶啥戚
例:
遣莫捅炭
此代码将创建要在数组中包含的复选框的数组。然后,当您单击一个或有一个按钮时,它将向您显示消息,该按钮将为您提供所有复选框的实际状态。 希望对您有所帮助 再见