Esempio n. 1
0
 /// <summary>
 /// Sets the value of the attached <see cref="NameScopeProperty"/> on a visual.
 /// </summary>
 /// <param name="visual">The visual.</param>
 /// <param name="value">The value to set.</param>
 public static void SetNameScope(Visual visual, INameScope value)
 {
     visual.SetValue(NameScopeProperty, value);
 }
Esempio n. 2
0
        /// <summary>
        /// Sets the visual parent of the Visual.
        /// </summary>
        /// <param name="value">The visual parent.</param>
        private void SetVisualParent(Visual value)
        {
            if (_visualParent == value)
            {
                return;
            }
            
            var old = _visualParent;
            _visualParent = value;

            if (VisualRoot != null)
            {
                var e = new VisualTreeAttachmentEventArgs(VisualRoot);
                NotifyDetachedFromVisualTree(e);
            }

            if (_visualParent is IRenderRoot || _visualParent?.IsAttachedToVisualTree == true)
            {
                var root = this.GetVisualAncestors().OfType<IRenderRoot>().FirstOrDefault();
                var e = new VisualTreeAttachmentEventArgs(root);
                NotifyAttachedToVisualTree(e);
            }

            RaisePropertyChanged(VisualParentProperty, old, value, BindingPriority.LocalValue);
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the visual parent of the Visual.
        /// </summary>
        /// <param name="value">The visual parent.</param>
        private void SetVisualParent(Visual value)
        {
            if (this.visualParent != value)
            {
                var old = this.visualParent;
                var oldRoot = this.GetVisualAncestors().OfType<IRenderRoot>().FirstOrDefault();
                var newRoot = default(IRenderRoot);

                if (value != null)
                {
                    newRoot = value.GetSelfAndVisualAncestors().OfType<IRenderRoot>().FirstOrDefault();
                }

                this.visualParent = value;

                if (oldRoot != null)
                {
                    this.NotifyDetachedFromVisualTree(oldRoot);
                }

                if (newRoot != null)
                {
                    this.NotifyAttachedToVisualTree(newRoot);
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Gets the value of the attached <see cref="NameScopeProperty"/> on a visual.
 /// </summary>
 /// <param name="visual">The visual.</param>
 /// <returns>The value of the NameScope attached property.</returns>
 public static INameScope GetNameScope(Visual visual)
 {
     return visual.GetValue(NameScopeProperty);
 }
Esempio n. 5
0
        /// <summary>
        /// Sets the visual parent of the Visual.
        /// </summary>
        /// <param name="value">The visual parent.</param>
        private void SetVisualParent(Visual value)
        {
            if (_visualParent != value)
            {
                var old = _visualParent;
                var oldRoot = this.GetVisualAncestors().OfType<IRenderRoot>().FirstOrDefault();
                var newRoot = default(IRenderRoot);

                if (value != null)
                {
                    newRoot = value.GetSelfAndVisualAncestors().OfType<IRenderRoot>().FirstOrDefault();
                }

                _visualParent = value;

                if (oldRoot != null)
                {
                    NotifyDetachedFromVisualTree(oldRoot);
                }

                if (newRoot != null)
                {
                    NotifyAttachedToVisualTree(newRoot);
                }

                RaisePropertyChanged(VisualParentProperty, old, value, BindingPriority.LocalValue);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Sets the visual parent of the Visual.
        /// </summary>
        /// <param name="value">The visual parent.</param>
        private void SetVisualParent(Visual value)
        {
            if (_visualParent == value)
            {
                return;
            }
            
            var old = _visualParent;

            if (_isAttachedToVisualTree)
            {
                var oldArgs = GetAttachmentEventArgs();

                _visualParent = value;

                if (oldArgs != null)
                {
                    NotifyDetachedFromVisualTree(oldArgs);
                }
            }
            else
            {
                _visualParent = value;
            }

            if (_visualParent is IRenderRoot || _visualParent?.IsAttachedToVisualTree == true)
            {
                var newArgs = GetAttachmentEventArgs();

                if (newArgs != null)
                {
                    NotifyAttachedToVisualTree(newArgs);
                }
            }

            RaisePropertyChanged(VisualParentProperty, old, value, BindingPriority.LocalValue);
        }
Esempio n. 7
0
        /// <summary>
        /// Removes a visual child from the control;
        /// </summary>
        /// <param name="visual">The child to remove.</param>
        protected void RemoveVisualChild(Visual visual)
        {
            Contract.Requires<ArgumentNullException>(visual != null);

            this.visualChildren.Remove(visual);
        }
Esempio n. 8
0
 protected virtual void OnVisualParentChanged(Visual oldParent)
 {
 }
Esempio n. 9
0
        /// <summary>
        /// Sets the visual parent of the Visual.
        /// </summary>
        /// <param name="value">The visual parent.</param>
        private void SetVisualParent(Visual value)
        {
            if (_visualParent != value)
            {
                var oldArgs = GetAttachmentEventArgs();

                _visualParent = value;

                if (oldArgs != null)
                {
                    NotifyDetachedFromVisualTree(oldArgs);
                }

                var newArgs = GetAttachmentEventArgs();

                if (newArgs != null)
                {
                    NotifyAttachedToVisualTree(newArgs);
                }

                RaisePropertyChanged(VisualParentProperty, oldArgs, value, BindingPriority.LocalValue);
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Sets the value of the attached <see cref="NameScopeProperty"/> on a visual.
 /// </summary>
 /// <param name="visual">The visual.</param>
 /// <param name="value">The value to set.</param>
 public static void SetNameScope(Visual visual, INameScope value)
 {
     visual.SetValue(NameScopeProperty, value);
 }
Esempio n. 11
0
 /// <summary>
 /// Gets the value of the attached <see cref="NameScopeProperty"/> on a visual.
 /// </summary>
 /// <param name="visual">The visual.</param>
 /// <returns>The value of the NameScope attached property.</returns>
 public static INameScope GetNameScope(Visual visual)
 {
     return(visual.GetValue(NameScopeProperty));
 }