private ContentControl GenerateHintItem(Hint hint) { var container = new ContentControl(); var element = VisualTreeHelperExtensions.GetChildByName(Window.Current.Content as Control, hint.PlacementTargetName); Rect elementRect = VisualTreeHelperExtensions.GetElementRect(element); PlacementMode placement = hint.Placement; container.Width = hint.Width != 0 ? hint.Width : 50; container.Height = hint.Height != 0 ? hint.Height : 50; container.Content = hint.Content; double left = 0; double top = 0; Style style = null; switch (placement) { case PlacementMode.Bottom: { left = elementRect.Left + elementRect.Width / 2 - container.Width / 2; top = elementRect.Top + elementRect.Height; style = this.BottomHintStyle; } break; case PlacementMode.Top: { left = elementRect.Left + elementRect.Width / 2 - container.Width / 2; top = elementRect.Top - container.Height; style = this.TopHintStyle; } break; case PlacementMode.Left: { left = elementRect.Left - container.Width; top = elementRect.Top + elementRect.Height / 2 - container.Height / 2; style = this.LeftHintStyle; } break; case PlacementMode.Right: { left = elementRect.Left + elementRect.Width; top = elementRect.Top + elementRect.Height / 2 - container.Height / 2; style = this.RightHintStyle; } break; } container.Margin = new Thickness(left, top, 0, 0); container.SetValue(ToolTip.StyleProperty, style); return container; }