namespace WebSite.Docus.Inputs.CheckLists;
class CheckList1 : BaseComponent
{
private readonly string Codes = "孙膑,后羿,妲己";
private readonly CodeInfo[] Items = new CodeInfo[]
{
new CodeInfo("1", "辅助"),
new CodeInfo("2", "射手"),
new CodeInfo("3", "法师")
};
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
//Codes属性设置列表项
//该值为数据字典类别或逗号分割的字符串
builder.Field<CheckList>("示例1:", "CheckList1").Set(f => f.Codes, Codes).Build();
//Items属性设置列表项
builder.Field<CheckList>("示例2:", "CheckList2").Set(f => f.Items, Items).Build();
//赋值
builder.Field<CheckList>("示例3:", "CheckList3").Value("孙膑,妲己").Set(f => f.Codes, Codes).Build();
builder.Field<CheckList>("示例4:", "CheckList4").Value("3").Set(f => f.Items, Items).Build();
builder.Field<CheckList>("平原模式:", "CheckList5").Value("1,3")
.Set(f => f.IsPlain, true)
.Set(f => f.Items, Items)
.Build();
}
}
namespace WebSite.Docus.Inputs.CheckLists;
class CheckList2 : BaseComponent
{
private CheckList? checkList;
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.Component<FieldControl>()
.Set(c => c.OnVisibleChanged, OnVisibleChanged)
.Set(c => c.OnEnabledChanged, OnEnabledChanged)
.Set(c => c.OnReadOnlyChanged, OnReadOnlyChanged)
.Set(c => c.SetValue, SetValue)
.Set(c => c.GetValue, GetValue)
.Build();
builder.Field<CheckList>("英雄:", "CheckList")
.Set(f => f.Codes, "孙膑,后羿,妲己")
.Build(value => checkList = value);
}
private void OnVisibleChanged(bool value) => checkList?.SetVisible(value);
private void OnEnabledChanged(bool value) => checkList?.SetEnabled(value);
private void OnReadOnlyChanged(bool value) => checkList?.SetReadOnly(value);
private void SetValue() => checkList?.SetValue("孙膑,妲己");
private string? GetValue() => checkList?.Value;
}