I am customizing the tooltip on my user control so that it looks like a callout. The tooltip is set to appear above the control (Placement=Top) with an arrow pointing down toward it.
The problem is when the control is near the edge of the screen, the tooltip is not aligned to the left-side of the control. As a result, the arrow points to an empty space to the left of the control.
Even worse, if the control is near the top of the screen, the tooltip shows up below the target control and the arrow pointing down.
Any idea how to resolve this? I am looking for some way to programmatically create the tooltip on the fly or set a trigger to select the Style based on some properties in the tooltip but I don’t know how.
I have faced the same problem in the past and what I did was get the position of the
PlacementTargetviaPointToScreen(new Point(0,0))and get the position of theToolTipby calling the same method and then doing the math to figure out whether theToolTipis correctly positioned or not. If it wasn’t, then I changed thePlacementof theToolTipaccording to whether it was showing up to the left, right, above or below thePlacementTarget. Also, keep in mind, thatPointToScreen()will only work once theToolTiphas rendered so attach a handler toToolTip.Openand do it in there. Hope this helped. Let me know if you come across a more efficient/better way to solve this problem.