private void menuTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { e.Handled = true; TreeViewData.TreeNode node = e.NewValue as TreeViewData.TreeNode; if (node == null) { _logHelper.LogInfo(string.Format("{1}。{0}未能解析TreeViewData.TreeNodeData。", Environment.NewLine, OperationDesc.OpenFunc)); MessageWindow.ShowMsg(MessageType.Error, OperationDesc.OpenFunc, MsgConst.Msg_ViewAppLog); return; } if (node.Data == null) { _logHelper.LogInfo(string.Format("{1}。{0}未能解析TreeViewData.TreeNodeData。{0}FuncName:{2}", Environment.NewLine, OperationDesc.OpenFunc, node.Label)); MessageWindow.ShowMsg(MessageType.Error, OperationDesc.OpenFunc, MsgConst.Msg_ViewAppLog); return; } if (node.SubNodes != null && node.SubNodes.Count > 0) { return; } var per = node.Data as Permission; _cmdOpenFunc.Execute(new OpenFuncParam { PageUri = per.per_uri, FuncCode = per.per_code }); //报告当前位置 lblCurrLocation.Content = node.GetNodePath(); }
private void CollectSelNodes(TreeViewData.TreeNode parent, List <TreeViewData.TreeNode> target) { if (parent.SubNodes == null || parent.SubNodes.Count < 1) { return; } var selNodes = parent.SubNodes.Where(n => n.IsChecked == true); if (selNodes == null || selNodes.Count() < 1) { return; } foreach (var node in selNodes) { target.Add(node); CollectSelNodes(node, target); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { TreeViewData.TreeNode selNode = (gpTree.SelectedItem as TreeViewData.TreeNode); TreeViewData.TreeNode node = new TreeViewData.TreeNode { Label = "新增党组织" }; if (selNode == null || _gpTreeData.RootNodes.Contains(selNode)) { node.Level = 1; _gpTreeData.RootNodes.Add(node); } else { node.ParentNode = selNode.ParentNode; node.Parent = selNode.Parent; node.Level = selNode.Level; selNode.ParentNode.SubNodes.Add(node); } }