/// <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); }
/// <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); }
/// <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); } } }
/// <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); }
/// <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); } }
/// <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); }
/// <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); }
protected virtual void OnVisualParentChanged(Visual oldParent) { }
/// <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); } }
/// <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)); }