Пример #1
0
        public static ObservableDataTreeNode CreateParentNode(object nodeValue, Func<object, Task<List<object>>> query)
        {
            var newNode = new ObservableDataTreeNode(nodeValue, DataTreeNodeState.ValidData);
            newNode.HasChildren = true;
            newNode.queryChildren = query;

            return newNode;
        }
Пример #2
0
        private async void StartQueryChildren(ObservableDataTreeNode node)  // TODO: NoWait();
        {
            if (node.State.HasFlag(DataTreeNodeState.ValidChildren))
            {
                return;
            }

            if (queryChildren == null)
            {
                node.State = DataTreeNodeState.Error;
                return;
            }

            try
            {
                StatusVisibility = Visibility.Visible;

                Task<List<object>> queryChildrenTask = queryChildren(node.Content);
                var children = await queryChildrenTask;

                RemoveAllChildren();
                foreach (var child in children)
                {
                    node.AddChild(ObservableDataTreeNode.CreateParentNode(child, queryChildren));
                }
                node.State |= DataTreeNodeState.ValidChildren;

                StatusVisibility = Visibility.Collapsed;
            }
            catch
            {
                node.State = DataTreeNodeState.Error;
            }
        }