internal async Task SetSelectedNodeAsync(TNode node) { this.SelectedNode = node; await SelectedNodeChanged.InvokeAsync(node); StateHasChanged(); }
/// <summary> /// 更新绑定数据 /// </summary> private void UpdateBindData() { if (SelectedNodesDictionary.Count == 0) { SelectedKey = null; SelectedNode = null; SelectedData = default(TItem); SelectedKeys = Array.Empty <string>(); SelectedNodes = Array.Empty <TreeNode <TItem> >(); SelectedDatas = Array.Empty <TItem>(); } else { var selectedFirst = SelectedNodesDictionary.FirstOrDefault(); SelectedKey = selectedFirst.Value?.Key; SelectedNode = selectedFirst.Value; SelectedData = selectedFirst.Value.DataItem; SelectedKeys = SelectedNodesDictionary.Select(x => x.Value.Key).ToArray(); SelectedNodes = SelectedNodesDictionary.Select(x => x.Value).ToArray(); SelectedDatas = SelectedNodesDictionary.Select(x => x.Value.DataItem).ToArray(); } if (SelectedKeyChanged.HasDelegate) { SelectedKeyChanged.InvokeAsync(SelectedKey); } if (SelectedNodeChanged.HasDelegate) { SelectedNodeChanged.InvokeAsync(SelectedNode); } if (SelectedDataChanged.HasDelegate) { SelectedDataChanged.InvokeAsync(SelectedData); } if (SelectedKeysChanged.HasDelegate) { SelectedKeysChanged.InvokeAsync(SelectedKeys); } }
private void OnSelectNode(TNode node) { SelectedNode = node; SelectedNodeChanged.InvokeAsync(node); }