using System.Threading.Tasks; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; namespace AntDesign { public partial class TreeNodeCheckbox : ComponentBase { /// /// Root Tree /// [CascadingParameter(Name = "Tree")] public Tree TreeComponent { get; set; } /// /// Current Node /// [CascadingParameter(Name = "SelfNode")] public TreeNode SelfNode { get; set; } protected ClassMapper ClassMapper { get; } = new ClassMapper(); private void SetClassMap() { ClassMapper .Add("ant-tree-checkbox") .If("ant-tree-checkbox-checked", () => SelfNode.Checked) .If("ant-tree-checkbox-indeterminate", () => SelfNode.Indeterminate) .If("ant-tree-checkbox-disabled", () => SelfNode.Disabled || SelfNode.DisableCheckbox); } protected override void OnInitialized() { SetClassMap(); base.OnInitialized(); } [Parameter] public EventCallback OnCheckBoxClick { get; set; } private async Task OnClick(MouseEventArgs args) { if (OnCheckBoxClick.HasDelegate) await OnCheckBoxClick.InvokeAsync(args); } } }