/// <summary> /// Attaches a HelpFrame instance to the layer for the given element. /// </summary> /// <param name="element">UIElement instance.</param> private void Attach(UIElement element) { _attachedElement = element; // Get the text that is associated with the element this.Text = GetHelpText(element); // get the HelpLayer var panel = TreeHelpers.GetRootPanel(); var layer = GetLayer(panel); if (layer != null) { // set the initial position of the frame var pos = element.GetPosition(panel); this.Margin = new Thickness(pos.X, pos.Y, 0, 0); this.HorizontalAlignment = HorizontalAlignment.Left; this.VerticalAlignment = VerticalAlignment.Top; layer.AttachFrame(this); } }