// Token: 0x06007823 RID: 30755 RVA: 0x00223D25 File Offset: 0x00221F25
 private void ClearModelParent(object item)
 {
     if (this.ModelParentFE != null && item is DependencyObject)
     {
         LogicalTreeHelper.RemoveLogicalChild(this.ModelParentFE, null, item);
     }
 }
Beispiel #2
0
 // if item implements IModelTree, clear model parent
 void ClearModelParent(object item)
 {
     // ClearModelParent is also called for items that are not a DependencyObject;
     // to avoid the unnecessary, expensive code in RemoveLogicalChild, check for DO first
     if ((ModelParentFE != null) && (item is DependencyObject))
     {
         LogicalTreeHelper.RemoveLogicalChild(ModelParentFE, null, item);
     }
 }
        /// <summary>
        /// Invoked when the <see cref="Content" /> property changes.
        /// </summary>
        /// <param name="oldContent">The old value of the <see cref="Content" /> property.</param>
        /// <param name="newContent">The new value of the <see cref="Content" /> property.</param>
        protected virtual void OnContentChanged(object oldContent, object newContent)
        {
            var oldElement = oldContent as UIElement;

            if (oldElement != null)
            {
                oldElement.LayoutUpdated -= this.OnContentLayoutUpdated;
            }

            var newContentDO = newContent as DependencyObject;

            if (newContentDO != null)
            {
                var newElement = newContent as UIElement;
                if (newElement != null)
                {
                    newElement.LayoutUpdated += this.OnContentLayoutUpdated;
                }

                var parent = LogicalTreeHelper.GetParent(newContentDO);
                if (parent != null)
                {
                    LogicalTreeHelper.RemoveLogicalChild(parent, newContent);
                }
            }

            DataTemplateSelector templateSelector;

            if (newContent != null && (templateSelector = this.ContentTemplateSelector) != null)
            {
                this.ApplyContentTemplate(templateSelector.SelectTemplate(newContent, this));
            }

            if (this.contentTemplateInstance != null)
            {
                this.contentTemplateInstance.DataContext = newContent;
            }
            else
            {
                this.AddLogicalChild(newContent);
            }

            this.OnNativeContentChanged(oldContent, newContent);
            this.RemoveLogicalChild(oldContent);
            this.InvalidateMeasure();
        }
Beispiel #4
0
        /// <summary>
        ///     This method is invoked when the Content property changes.
        /// </summary>
        /// <param name="oldContent">The old value of the Content property.</param>
        /// <param name="newContent">The new value of the Content property.</param>
        protected virtual void OnContentChanged(object oldContent, object newContent)
        {
            // Remove the old content child
            RemoveLogicalChild(oldContent);

            // if Content should not be treated as a logical child, there's
            // nothing to do
            if (ContentIsNotLogical)
            {
                return;
            }

            DependencyObject d = newContent as DependencyObject;

            if (d != null)
            {
                DependencyObject logicalParent = LogicalTreeHelper.GetParent(d);
                if (logicalParent != null)
                {
                    if (TemplatedParent != null && FrameworkObject.IsEffectiveAncestor(logicalParent, this))
                    {
                        // In the case that this ContentControl belongs in a parent template
                        // and represents the content of a parent, we do not wish to change
                        // the logical ancestry of the content.
                        return;
                    }
                    else
                    {
                        // If the new content was previously hooked up to the logical
                        // tree then we sever it from the old parent.
                        LogicalTreeHelper.RemoveLogicalChild(logicalParent, newContent);
                    }
                }
            }

            // Add the new content child
            AddLogicalChild(newContent);
        }
        /// <summary> Called when the <see cref="P:System.Windows.Controls.ContentControl.Content" /> property changes. </summary>
        /// <param name="oldContent">The old value of the <see cref="P:System.Windows.Controls.ContentControl.Content" /> property.</param>
        /// <param name="newContent">The new value of the <see cref="P:System.Windows.Controls.ContentControl.Content" /> property.</param>
        // Token: 0x060043DB RID: 17371 RVA: 0x00135DDC File Offset: 0x00133FDC
        protected virtual void OnContentChanged(object oldContent, object newContent)
        {
            base.RemoveLogicalChild(oldContent);
            if (this.ContentIsNotLogical)
            {
                return;
            }
            DependencyObject dependencyObject = newContent as DependencyObject;

            if (dependencyObject != null)
            {
                DependencyObject parent = LogicalTreeHelper.GetParent(dependencyObject);
                if (parent != null)
                {
                    if (base.TemplatedParent != null && FrameworkObject.IsEffectiveAncestor(parent, this))
                    {
                        return;
                    }
                    LogicalTreeHelper.RemoveLogicalChild(parent, newContent);
                }
            }
            base.AddLogicalChild(newContent);
        }