コード例 #1
0
        private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var node = DataContext as INode;

            if (node == null)
            {
                // there seem to be reasons where DataContext is MS.Internal.NamedObject
                // but it is unclear yet which reasons.
                // -> ignore this invalid state for the moment
                return;
            }

            State = myStateContainer.GetOrCreate(node);
            State.Attach(this);

            var childrenCount = (TextBlock)GetTemplateChild("PART_ChildrenCount");

            if (childrenCount != null)
            {
                var expr = BindingOperations.GetMultiBindingExpression(childrenCount, TextBlock.TextProperty);
                expr.UpdateTarget();
            }
        }
コード例 #2
0
 public NodeState GetParent(NodeState state)
 {
     return(state.DataContext.Parent == null ? null : myContainer.GetOrCreate(state.DataContext.Parent));
 }