public static void SetAdornedElement(Visual adorner, Visual adorned) { adorner.SetValue(AdornedElementProperty, adorned); }
private void UpdateAdornedElement(Visual adorner, Visual adorned) { var info = adorner.GetValue(s_adornedElementInfoProperty); if (info != null) { info.Subscription.Dispose(); if (adorned == null) { adorner.ClearValue(s_adornedElementInfoProperty); } } if (adorned != null) { if (info == null) { info = new AdornedElementInfo(); adorner.SetValue(s_adornedElementInfoProperty, info); } info.Subscription = _tracker.Track(adorned).Subscribe(x => { info.Bounds = x; InvalidateArrange(); }); } }
public override bool ApplyTemplate() { if (this.IsInitialized && this.visualChild == null) { Visual visual = this.Content as Visual; if (visual == null && this.Content != null) { DataTemplate template = this.ContentTemplate; if (template == null) { DataTemplateKey key = new DataTemplateKey(this.Content.GetType()); template = this.TryFindResource(key) as DataTemplate; } if (template != null) { visual = template.CreateVisualTree(this); FrameworkElement fe = visual as FrameworkElement; if (fe != null) { fe.DataContext = this.Content; } } else { visual = new TextBlock { Text = this.Content.ToString(), }; } } if (visual != null) { this.visualChild = visual; this.AddVisualChild(this.visualChild); this.OnApplyTemplate(); return true; } } return false; }
public static Visual GetAdornedElement(Visual adorner) { return adorner.GetValue(AdornedElementProperty); }
/// <summary> /// Gets the transformed bounds of the visual. /// </summary> /// <param name="visual">The visual.</param> /// <returns>The transformed bounds.</returns> public static TransformedBounds GetTransformedBounds(Visual visual) => visual.GetValue(TransformedBoundsProperty);
private void ContentChanged(object oldValue, object newValue) { if (oldValue != null) { this.RemoveLogicalChild(oldValue); this.RemoveVisualChild(this.visualChild); this.visualChild = null; } if (newValue != null) { this.AddLogicalChild(newValue); } this.ApplyTemplate(); }
/// <summary> /// Starts tracking the specified visual. /// </summary> /// <param name="visual">The visual.</param> /// <returns>An observable that returns the tracked bounds.</returns> public IObservable<TransformedBounds> Track(Visual visual) { return visual.GetObservable(TransformedBoundsProperty); }
internal static void SetTransformedBounds(Visual visual, TransformedBounds bounds) { visual.SetValue(TransformedBoundsProperty, bounds); }
public PointHitTestResult(Visual visualHit, Point pointHit) { this.VisualHit = visualHit; this.PointHit = pointHit; }
/// <summary> /// Removes a child <see cref="Visual"/> from the visual tree. /// </summary> /// <param name="child">The child visual.</param> protected internal void RemoveVisualChild(Visual child) { child.VisualParent = null; child.DependencyParent = null; }
/// <summary> /// Adds a child <see cref="Visual"/> to the visual tree. /// </summary> /// <param name="child">The child visual.</param> protected internal void AddVisualChild(Visual child) { if (child == null) { throw new ArgumentNullException("child"); } DependencyObject oldParent = child.VisualParent; child.DependencyParent = this; child.VisualParent = this; child.OnVisualParentChanged(oldParent); }
public sealed override bool ApplyTemplate() { if (this.IsInitialized && this.child == null) { if (this.Template == null) { this.ApplyTheme(); } if (this.Template != null) { this.child = this.Template.CreateVisualTree(this); this.AddVisualChild(this.child); this.OnApplyTemplate(); return true; } } return false; }