예제 #1
0
        internal virtual void OnChildrenReset()
        {
            if (this.INTERNAL_VisualChildrenInformation != null)
            {
                foreach (var childInfo in this.INTERNAL_VisualChildrenInformation.Select(kp => kp.Value).ToArray())
                {
                    INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(childInfo.INTERNAL_UIElement, this);
                }
            }

            if (!this.HasChildren)
            {
                return;
            }

            if (this._enableProgressiveRendering || this.INTERNAL_EnableProgressiveLoading)
            {
                this.ProgressivelyAttachChildren(this.Children);
            }
            else
            {
                for (int i = 0; i < this.Children.Count; ++i)
                {
                    INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(this.Children[i], this, i);
                }
            }
        }
예제 #2
0
        protected internal override void INTERNAL_OnAttachedToVisualTree()
        {
            // We update the ItemsPanel only if there is no ControlTemplate.
            // Otherwise, it will be done in the "OnApplyTemplate" method.
            base.INTERNAL_OnAttachedToVisualTree();

            if (!this.HasTemplate)
            {
                // If we have no template we have to create an ItemPresenter
                // manually and attach it to this control.
                // This can happen for instance if a class derive from
                // ItemsControl and specify a DefaultStyleKey and the associated
                // default style does not contain a Setter for the Template
                // property.
                // Note: this is a Silverlight specific behavior.
                // In WPF the content of the ItemsControl would simply not be
                // displayed in this scenario.
                this._itemsPresenter = new ItemsPresenter();
                this._itemsPresenter.AttachToOwner(this);

#if REWORKLOADED
                this.AddVisualChild(this._itemsPresenter);
#else
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(this._itemsPresenter, this);
#endif

                // we need to set this variable so that if we move from no
                // template to a template, the "manually generated" template
                // will be detached as expected.
                this._renderedControlTemplate = this._itemsPresenter;
            }
        }
예제 #3
0
 protected internal override void INTERNAL_OnAttachedToVisualTree()
 {
     foreach (Inline child in this._inlines)
     {
         INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(child, this);
     }
 }
예제 #4
0
        protected void OnContentChanged(object oldContent, object newContent)
#endif
        {
            if (_isLoaded)
            {
                // Due to the fact that the children fill their "ParentWindow"
                // property by copying the value of the "ParentWindow" property
                // of their parent, we need to temporarily set it to be equal
                // to "this" before calling "base.OnContentChanged", so that it
                // then gets passed to the children recursively:
                this.INTERNAL_ParentWindow = this;

                // Attach the child UI element:
#if RECURSIVE_CONSTRUCTION_FIXED
                base.OnContentChanged(oldContent, newContent);
#else
                UIElement newChild = newContent as UIElement;
                UIElement oldChild = oldContent as UIElement;

                INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(oldChild, this);
                RemoveVisualChild(oldChild);
                AddVisualChild(newChild);
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(newChild, this);
#endif
                // We can now revert the "ParentWindow" to null (cf. comment above):
                this.INTERNAL_ParentWindow = null;


                // Reset the print area so that it becomes the window root control:
#if OPENSILVER
                if (false)
#elif BRIDGE
                if (!CSHTML5.Interop.IsRunningInTheSimulator)
#endif
                {
                    if (CSHTML5.Native.Html.Printing.PrintManager.IsDefaultPrintArea)
                    {
                        CSHTML5.Native.Html.Printing.PrintManager.ResetPrintArea();
                    }
                }

                Application.Current.TextMeasurementService.CreateMeasurementText(this);

                /*
                 * // Invalidate when content changed
                 * InvalidateMeasure();
                 * InvalidateArrange();
                 *
                 * // At the first contentChanged, InvaliateMeasure/Arrange does not work because IsArrangeValid and IsMeasureValid is false.
                 * if (CSHTML5.Interop.IsRunningInTheSimulator_WorkAround)
                 * {
                 *  Debug.WriteLine("Delayed CalculateWindowLayout");
                 *  // On the simulator, Window Bounds height is zero at the startup.
                 *  Task.Delay(500).ContinueWith(t => CalculateWindowLayout());
                 * }
                 * else
                 *  CalculateWindowLayout();*/
                // Disabled for CustomLayout
            }
        }
예제 #5
0
 protected override void OnTextAddedOverride(TextElement textElement)
 {
     if (INTERNAL_VisualTreeManager.IsElementInVisualTree(this.Paragraph))
     {
         INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(textElement, this.Paragraph);
     }
 }
예제 #6
0
        /// <summary>
        /// Creates an instance of the Template, attaches it to the Visual Tree, and calls "OnApplyTemplate". This method is intented to be called for ControlTemplates only (not DataTemplates).
        /// </summary>
        /// <param name="templateOwner">The owner of the template is the control to which the template is applied.</param>
        /// <returns>The instantiated control template.</returns>
        internal FrameworkElement INTERNAL_InstantiateAndAttachControlTemplate(Control templateOwner)
        {
            if (_methodToInstantiateFrameworkTemplate != null)
            {
                if (templateOwner != null)
                {
                    // Instantiate the ControlTemplate:
                    TemplateInstance templateInstance = _methodToInstantiateFrameworkTemplate(templateOwner);

                    // Attach it:
                    INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(templateInstance.TemplateContent, templateOwner);

                    // Raise the "OnApplyTemplate" property:
                    if (templateOwner != null)
                    {
                        templateOwner.RaiseOnApplyTemplate();
                    }
                    return(templateInstance.TemplateContent);
                }
                else
                {
                    throw new ArgumentNullException("templateOwner");
                }
            }
            else
            {
                throw new Exception("The FrameworkTemplate was not properly initialized.");
            }
        }
예제 #7
0
        internal virtual void OnChildrenReset()
        {
            if (this.INTERNAL_VisualChildrenInformation != null)
            {
                foreach (var childInfo in this.INTERNAL_VisualChildrenInformation.Select(kp => kp.Value).ToArray())
                {
                    INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(childInfo.INTERNAL_UIElement, this);
                }
            }

            if (this.EnableProgressiveRendering)
            {
                this.ProgressivelyAttachChildren(this.Children);
            }
            else
            {
                for (int i = 0; i < this.Children.Count; ++i)
                {
#if REWORKLOADED
                    this.AddVisualChild(this.Children[i], i);
#else
                    INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(this.Children[i], this, i);
#endif
                }
            }
        }
예제 #8
0
        /// <summary>
        /// Creates an instance of the Template, attaches it to the Visual Tree, and calls "OnApplyTemplate". This method is intented to be called for ControlTemplates only (not DataTemplates).
        /// </summary>
        /// <param name="templateOwner">The owner of the template is the control to which the template is applied.</param>
        /// <returns>The instantiated control template.</returns>
        internal FrameworkElement INTERNAL_InstantiateAndAttachControlTemplate(Control templateOwner)
        {
            if (templateOwner == null)
            {
                throw new ArgumentNullException("templateOwner");
            }

            templateOwner.INTERNAL_IsTemplated = true;

            if (_methodToInstantiateFrameworkTemplate != null)
            {
                // Instantiate the ControlTemplate:
                TemplateInstance templateInstance = _methodToInstantiateFrameworkTemplate(templateOwner);

                // Attach it:
#if REWORKLOADED
                templateOwner.AddVisualChild(templateInstance.TemplateContent);
#else
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(templateInstance.TemplateContent, templateOwner);
#endif

                // Raise the "OnApplyTemplate" property:
                if (templateOwner != null)
                {
                    templateOwner.RaiseOnApplyTemplate();
                }
                return(templateInstance.TemplateContent);
            }
            else
            {
                return(null);
            }
        }
예제 #9
0
        protected internal override void INTERNAL_OnAttachedToVisualTree()
        {
            // we need the TileView to be set before calling OnChildrenReset,
            // which is done in the base implementation.
            this._owner = ItemsControl.GetItemsOwner(this) as TileView;

            if (this._contentGrid == null)
            {
                var grid    = new GridNotLogical();
                var column1 = new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Star)
                };
                var column2 = new ColumnDefinition();
                grid.ColumnDefinitions.Add(column1);
                grid.ColumnDefinitions.Add(column2);
                this._contentGrid = grid;
            }

            BindingOperations.SetBinding(
                this._contentGrid.ColumnDefinitions[1],
                ColumnDefinition.WidthProperty,
                new Binding("MinimizedColumnWidth")
            {
                Source = this._owner
            });

            base.INTERNAL_OnAttachedToVisualTree();

            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(this._contentGrid, this, 0);
        }
예제 #10
0
        protected void OnContentChanged(object oldContent, object newContent)
#endif
        {
            if (_isLoaded)
            {
                // Due to the fact that the children fill their "ParentWindow"
                // property by copying the value of the "ParentWindow" property
                // of their parent, we need to temporarily set it to be equal
                // to "this" before calling "base.OnContentChanged", so that it
                // then gets passed to the children recursively:
                this.INTERNAL_ParentWindow = this;

                // Attach the child UI element:
#if RECURSIVE_CONSTRUCTION_FIXED
                base.OnContentChanged(oldContent, newContent);
#else
                INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(oldContent as UIElement, this);
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(newContent as UIElement, this);
#endif
                // We can now revert the "ParentWindow" to null (cf. comment above):
                this.INTERNAL_ParentWindow = null;


                // Reset the print area so that it becomes the window root control:
                if (!CSHTML5.Interop.IsRunningInTheSimulator)
                {
                    if (CSHTML5.Native.Html.Printing.PrintManager.IsDefaultPrintArea)
                    {
                        CSHTML5.Native.Html.Printing.PrintManager.ResetPrintArea();
                    }
                }
            }
        }
예제 #11
0
 protected internal override void INTERNAL_OnAttachedToVisualTree()
 {
     base.INTERNAL_OnAttachedToVisualTree();
     foreach (var inline in Inlines)
     {
         INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(inline, this);
     }
 }
예제 #12
0
 protected internal override void INTERNAL_OnAttachedToVisualTree()
 {
     base.INTERNAL_OnAttachedToVisualTree();
     foreach (var block in Blocks)
     {
         INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(block, this);
     }
 }
예제 #13
0
        internal virtual void OnChildrenAdded(UIElement newChild, int index)
        {
#if REWORKLOADED
            this.AddVisualChild(newChild, index);
#else
            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(newChild, this, index);
#endif
        }
예제 #14
0
        static void Content_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UIElement parent   = (UIElement)d;
            UIElement oldChild = (UIElement)e.OldValue;
            UIElement newChild = (UIElement)e.NewValue;

            INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(oldChild, parent);
            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(newChild, parent);
        }
예제 #15
0
        internal void OnPanelChangedInternal()
        {
            if (this.ItemsHost != null)
            {
#if WORKINPROGRESS
                // Panel is no longer ItemsHost
                this.ItemsHost.IsItemsHost = false;
#endif

                // Detach old panel
                INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(this.ItemsHost, this);
            }

            if (this._templateCache != null)
            {
                // Create an instance of the Panel
                FrameworkElement visualTree = this._templateCache.INTERNAL_InstantiateFrameworkTemplate(null);
                Panel            panel      = visualTree as Panel;
                if (panel != null)
                {
                    // Make sure that the panel contains no children
                    if (panel.Children.Count > 0)
                    {
                        throw new InvalidOperationException("VisualTree of ItemsPanelTemplate must be a single element.");
                    }

                    this._itemsHost = panel;

#if WORKINPROGRESS
                    // set IsItemsHost flag
                    panel.IsItemsHost = true;
#endif
                }
                else
                {
                    throw new InvalidOperationException(string.Format("VisualTree of ItemsPanelTemplate must contain a Panel. '{0}' is not a Panel.", visualTree.GetType()));
                }

                // attach the panel.
#if REWORKLOADED
                this.AddVisualChild(panel);
#else
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(panel, this);
#endif

                // Attach children to panel
                if (this.Owner != null)
                {
                    this.Owner.Refresh();
                }
            }
            else
            {
                this._itemsHost = null;
                this.Owner.ItemContainerGenerator.INTERNAL_Clear();
            }
        }
예제 #16
0
        protected internal override void INTERNAL_OnAttachedToVisualTree()
        {
            base.INTERNAL_OnAttachedToVisualTree();

#if REWORKLOADED
            AddVisualChild(_child);
#else
            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(_child, this);
#endif
        }
예제 #17
0
        private async void ProgressivelyAttachChildren(UIElementCollection newChildren)
        {
            foreach (UIElement child in newChildren)
            {
                await Task.Delay(1);

                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(child, this);
                INTERNAL_OnChildProgressivelyLoaded();
            }
        }
예제 #18
0
        protected override void OnTextAddedOverride(TextElement textElement)
        {
            if (INTERNAL_VisualTreeManager.IsElementInVisualTree(this.Span))
            {
#if REWORKLOADED
                this.Span.AddVisualChild(textElement);
#else
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(textElement, this.Span);
#endif
            }
        }
예제 #19
0
        protected internal override void INTERNAL_OnAttachedToVisualTree()
        {
            foreach (Inline child in this.Inlines)
            {
#if REWORKLOADED
                this.AddVisualChild(child);
#else
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(child, this);
#endif
            }
        }
예제 #20
0
        internal virtual void OnChildrenReplaced(UIElement oldChild, UIElement newChild, int index)
        {
            if (oldChild == newChild)
            {
                return;
            }

            INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(oldChild, this);

            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(newChild, this, index);
        }
예제 #21
0
        private async void ProgressivelyAttachChild()
        {
            await Task.Delay(1);

            if (!INTERNAL_VisualTreeManager.IsElementInVisualTree(this))
            {
                //this can happen if the Panel is detached during the delay.
                return;
            }
            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(_child, this);
        }
예제 #22
0
        protected internal override void INTERNAL_OnAttachedToVisualTree()
        {
            base.INTERNAL_OnAttachedToVisualTree();

            if (this.ItemsHost != null)
            {
#if REWORKLOADED
                this.AddVisualChild(this.ItemsHost);
#else
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(this.ItemsHost, this);
#endif
            }
        }
예제 #23
0
        protected internal override void INTERNAL_OnAttachedToVisualTree()
        {
            if (this.BorderBrush == null)
            {
                INTERNAL_PropertyStore.ApplyCssChanges(null, null, Border.BorderBrushProperty.GetMetadata(typeof(Border)), this);
            }

#if REWORKLOADED
            this.AddVisualChild(this._child);
#else
            INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(_child, this);
#endif
        }
예제 #24
0
        private async void ProgressivelyAttachChildren(IList <UIElement> newChildren)
        {
            for (int i = 0; i < newChildren.Count; ++i)
            {
                await Task.Delay(1);

                if (!INTERNAL_VisualTreeManager.IsElementInVisualTree(this))
                {
                    //this can happen if the Panel is detached during the delay.
                    break;
                }
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(newChildren[i], this);
                INTERNAL_OnChildProgressivelyLoaded();
            }
        }
예제 #25
0
        private async void ProgressivelyAttachChildren(UIElementCollection newChildren)
        {
            foreach (UIElement child in newChildren)
            {
                await Task.Delay(1);

                if (!INTERNAL_VisualTreeManager.IsElementInVisualTree(this))
                {
                    //this can happen if the Panel is detached during the delay.
                    break;
                }
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(child, this);
                INTERNAL_OnChildProgressivelyLoaded();
            }
        }
예제 #26
0
        internal virtual void ManageChildrenChanged(UIElementCollection oldChildren, UIElementCollection newChildren)
        {
            if (oldChildren != null)
            {
                // Detach old children only if they are not in the "newChildren" collection:
                foreach (UIElement child in oldChildren) //note: there is no setter for Children so the user cannot change the order of the elements in one step --> we cannot have the same children in another order (which would keep the former order with the way it is handled now) --> no problem here
                {
#if PERFSTAT
                    var t2 = Performance.now();
#endif
                    if (newChildren == null || !newChildren.Contains(child))
                    {
#if PERFSTAT
                        Performance.Counter("Panel.ManageChildrenChanged 'Contains'", t2);
#endif
                        INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(child, this);
                    }
                    else
                    {
#if PERFSTAT
                        Performance.Counter("Panel.ManageChildrenChanged 'Contains'", t2);
#endif
                    }
                }
            }
            if (newChildren != null)
            {
                // Note: we attach all the children (regardless of whether they are in the oldChildren collection or not) to make it work when the item is first added to the Visual Tree (at that moment, all the properties are refreshed by calling their "Changed" method).

                if (this.EnableProgressiveRendering)
                {
                    this.ProgressivelyAttachChildren(newChildren);
                }
                else
                {
                    foreach (UIElement child in newChildren)
                    {
#if REWORKLOADED
                        this.AddVisualChild(child);
#else
                        INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(child, this);
#endif
                    }
                }
            }
        }
예제 #27
0
        protected virtual void UpdateItemsPanel(ItemsPanelTemplate newTemplate)
        {
            if (!_disableDefaultRendering)
            {
                if (_placeWhereItemsPanelWillBeRendered != null
                    //&& INTERNAL_VisualTreeManager.IsElementInVisualTree(_placeWhereItemsPanelWillBeRendered))
                    && _placeWhereItemsPanelWillBeRendered._isLoaded) //Note: we replaced "IsElementInVisualTree" with _isLoaded on on March 22, 2017 to fix an issue where a "Binding" on ListBox.ItemsSource caused the selection to not work properly. This change can be reverted the day that the implementation of the "IsElementInVisualTree" method becomes based on the "_isLoaded" property (at the time of writing, it was implemented by checking if the visual parent is null).
                {
                    INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(this._renderedItemsPanel, _placeWhereItemsPanelWillBeRendered);

                    if (newTemplate != null)
                    {
                        // Create an instance of the Panel:
                        _renderedItemsPanel = newTemplate.INTERNAL_InstantiateFrameworkTemplate();

                        // Make sure the panel derives from the type "Panel":
                        if (!(_renderedItemsPanel is Panel))
                        {
                            throw new InvalidOperationException("ItemsControl.ItemsPanelTemplate must derive from Panel.");
                        }

                        // Make sure that the panel contains no children:
                        if (((Panel)_renderedItemsPanel).Children != null && ((Panel)_renderedItemsPanel).Children.Count > 0)
                        {
                            throw new InvalidOperationException("Cannot explicitly modify Children collection of Panel used as ItemsPanel for ItemsControl. ItemsControl generates child elements for Panel.");
                        }

                        // Attach the panel:
                        INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(_renderedItemsPanel, _placeWhereItemsPanelWillBeRendered);

                        // Update the children:
                        if (_actualItemsSource != null)
                        {
                            OnItemsChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                            UpdateChildrenInVisualTree(_actualItemsSource, _actualItemsSource, forceUpdateAllChildren: true);
                        }
                    }
                    else
                    {
                        // The ItemsPanel is null, so we display nothing (like in WPF):
                        _renderedItemsPanel = null;
                        _itemContainerGenerator.INTERNAL_Clear();
                    }
                }
            }
        }
예제 #28
0
        private void ChangeChild(object newChild)
        {
            this.DetachChild(); // Detach current child.

            UIElement newChildAsUIElement = newChild as UIElement;

            if (newChildAsUIElement != null)
            {
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(newChildAsUIElement, this);
                this.Child = newChildAsUIElement;
            }
            else
            {
                string contentAsString = newChild == null ? string.Empty : newChild.ToString();
                INTERNAL_HtmlDomManager.SetContentString(this, contentAsString, removeTextWrapping: true);
                this.Child = this; // In the case where the child is not an UIElement, we consider the child to be this Control because we don't add a child (we directly set the content of this element).
            }
        }
예제 #29
0
        protected internal override void INTERNAL_OnAttachedToVisualTree()
        {
            base.INTERNAL_OnAttachedToVisualTree();

            if (this.BorderBrush == null)
            {
                INTERNAL_PropertyStore.ApplyCssChanges(null, null, Border.BorderBrushProperty.GetMetadata(typeof(Border)), this);
            }

            if (!this.INTERNAL_EnableProgressiveLoading)
            {
                INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(_child, this);
            }
            else
            {
                ProgressivelyAttachChild();
            }
        }
예제 #30
0
        //static void ContentTemplate_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        //{
        //    var contentControl = (ContentControl)d;
        //    object newText = e.NewValue;

        //    //todo: apply the new template to the content (if the content is set)

        //    //if (INTERNAL_VisualTreeManager.IsElementInVisualTree(contentControl))
        //    //    apply template
        //}



        /// <summary>
        /// Invoked when the value of 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)
        {
            if (!this.HasTemplate)
            {
                //-----------------------------
                // DETACH PREVIOUS CONTENT
                //-----------------------------
                if (oldContent is UIElement)
                {
                    INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull((UIElement)oldContent, this);
                }
                if (_dataTemplateRenderedContent != null)
                {
                    INTERNAL_VisualTreeManager.DetachVisualChildIfNotNull(_dataTemplateRenderedContent, this);
                }
                _dataTemplateRenderedContent = null;

                //-----------------------------
                // ATTACH NEW CONTENT
                //-----------------------------


                if (newContent is UIElement)
                {
                    INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached((UIElement)newContent, this);
                }
                else if (INTERNAL_VisualTreeManager.IsElementInVisualTree(this))
                {
                    if (ContentTemplate != null)
                    {
                        // Apply the data template:
                        _dataTemplateRenderedContent             = ContentTemplate.INTERNAL_InstantiateFrameworkTemplate();
                        _dataTemplateRenderedContent.DataContext = newContent;
                        INTERNAL_VisualTreeManager.AttachVisualChildIfNotAlreadyAttached(_dataTemplateRenderedContent, this);
                    }
                    else if (newContent != null)
                    {
                        // Show the string:
                        INTERNAL_HtmlDomManager.SetContentString(this, newContent.ToString(), removeTextWrapping: true);
                    }
                }
            }
        }