コード例 #1
0
        internal async Task SetSelectedNodeAsync(TNode node)
        {
            this.SelectedNode = node;
            await SelectedNodeChanged.InvokeAsync(node);

            StateHasChanged();
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
ファイル: TreeView.razor.cs プロジェクト: justindbaur/viking
 private void OnSelectNode(TNode node)
 {
     SelectedNode = node;
     SelectedNodeChanged.InvokeAsync(node);
 }