Exemplo n.º 1
0
        /// <summary>
        /// Expands the current branch if possible
        /// </summary>
        public void Expand()
        {
            if (ChildBranches == null)
            {
                FetchChildren();
            }

            if (ChildBranches.Any())
            {
                IsExpanded = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns true if the current branch can be expanded according to
        /// the <see cref="TreeBuilder{T}"/> or cached children already fetched
        /// </summary>
        /// <returns></returns>
        public bool CanExpand()
        {
            // if we do not know the children yet
            if (ChildBranches == null)
            {
                //if there is a rapid method for determining whether there are children
                if (tree.TreeBuilder.SupportsCanExpand)
                {
                    return(tree.TreeBuilder.CanExpand(Model));
                }

                //there is no way of knowing whether we can expand without fetching the children
                FetchChildren();
            }

            //we fetched or already know the children, so return whether we have any
            return(ChildBranches.Any());
        }