public Node()

in sources/Google.Solutions.Mvvm/Controls/BindableTreeView.cs [194:278]


            public Node(BindableTreeView<TModelNode> treeView, TModelNode modelNode)
            {
                this.treeView = treeView;
                this.Model = modelNode;

                //
                // Bind properties to keep TreeNode in sync with view model.
                // Note that binding is one-way (view model -> view) as TreeNodes
                // are not proper controls and do not provide the necessary events.
                //
                if (this.treeView.textExpression != null)
                {
                    this.Name = this.Text = this.treeView.textExpression.Compile()(this.Model);
                    this.bindings.Add(BindingExtensions.CreatePropertyChangeBinding(
                        this.Model,
                        this.treeView.textExpression,
                        text => this.Text = text));
                }

                if (this.treeView.imageIndexExpression != null)
                {
                    this.ImageIndex = this.treeView.imageIndexExpression.Compile()(this.Model);
                    if (!this.treeView.imageIndexExpressionReadonly)
                    {
                        this.bindings.Add(BindingExtensions.CreatePropertyChangeBinding(
                            this.Model,
                            this.treeView.imageIndexExpression,
                            iconIndex => this.ImageIndex = iconIndex));
                    }
                }

                if (this.treeView.selectedImageIndexExpression != null)
                {
                    this.SelectedImageIndex = this.treeView.selectedImageIndexExpression.Compile()(this.Model);
                    if (!this.treeView.selectedImageIndexExpressionReadonly)
                    {
                        this.bindings.Add(BindingExtensions.CreatePropertyChangeBinding(
                            this.Model,
                            this.treeView.selectedImageIndexExpression,
                            iconIndex => this.SelectedImageIndex = iconIndex));
                    }
                }

                if (this.treeView.isExpandedExpression != null)
                {
                    this.bindings.Add(BindingExtensions.CreatePropertyChangeBinding(
                        this.Model,
                        this.treeView.isExpandedExpression,
                        expanded =>
                        {
                            if (expanded)
                            {
                                Expand();
                            }
                            else
                            {
                                Collapse();
                            }
                        }));
                }

                if (this.treeView.isLeafFunc(this.Model))
                {
                    // This node does not have children.
                }
                else
                {
                    //
                    // This node might have children. Add a dummy node
                    // to ensure that the '+' control is being displayed.
                    //
                    this.Nodes.Add(new LoadingTreeNode());

                    if (this.treeView.isExpandedFunc(this.Model))
                    {
                        // Eagerly load children.
                        Expand();
                        LazyLoadChildren();
                    }
                    else
                    {
                        // Lazy load children. Nothing to do for now.
                    }
                }
            }