Beispiel #1
0
        private void SetTemplatedParentAndApplyChildTemplates(IControl control)
        {
            var templatedParent = Parent.TemplatedParent;

            if (control.TemplatedParent == null)
            {
                control.SetValue(TemplatedParentProperty, templatedParent);
            }

            control.ApplyTemplate();

            if (!(control is IPresenter && control.TemplatedParent == templatedParent))
            {
                foreach (IControl child in control.GetVisualChildren())
                {
                    SetTemplatedParentAndApplyChildTemplates(child);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets the TemplatedParent property for a control created from the control template and
        /// applies the templates of nested templated controls. Also adds each control to its name
        /// scope if it has a name.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="nameScope">The name scope.</param>
        private void SetupTemplateControls(IControl control, INameScope nameScope)
        {
            // If control.TemplatedParent is null at this point, then the control is our templated
            // child so set its TemplatedParent and register it with its name scope.
            if (control.TemplatedParent == null)
            {
                control.SetValue(TemplatedParentProperty, this);

                if (control.Name != null)
                {
                    nameScope.Register(control.Name, control);
                }
            }

            control.ApplyTemplate();

            if (!(control is IPresenter && control.TemplatedParent == this))
            {
                foreach (IControl child in control.GetVisualChildren())
                {
                    SetupTemplateControls(child, nameScope);
                }
            }
        }
        /// <summary>
        /// Sets the TemplatedParent property for a control created from the control template and
        /// applies the templates of nested templated controls. Also adds each control to its name
        /// scope if it has a name.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="nameScope">The name scope.</param>
        private void SetupTemplateControls(IControl control, INameScope nameScope)
        {
            // If control.TemplatedParent is null at this point, then the control is our templated
            // child so set its TemplatedParent and register it with its name scope.
            if (control.TemplatedParent == null)
            {
                control.SetValue(TemplatedParentProperty, this);

                if (control.Name != null)
                {
                    nameScope.Register(control.Name, control);
                }
            }

            control.ApplyTemplate();

            if (!(control is IPresenter && control.TemplatedParent == this))
            {
                foreach (IControl child in control.GetVisualChildren())
                {
                    SetupTemplateControls(child, nameScope);
                }
            }
        }
        /// <summary>
        /// Sets the TemplatedParent property for a control created from the control template and
        /// applies the templates of nested templated controls.
        /// </summary>
        /// <param name="control">The control.</param>
        private void SetTemplatedParentAndApplyChildTemplates(IControl control)
        {
            if (control.TemplatedParent == null)
            {
                control.SetValue(TemplatedParentProperty, this);
            }

            control.ApplyTemplate();

            if (!(control is IPresenter && control.TemplatedParent == this))
            {
                foreach (IControl child in control.GetVisualChildren())
                {
                    SetTemplatedParentAndApplyChildTemplates(child);
                }
            }
        }