XAML tooltips are being clipped
Question
I am trying to make a WPF app (regular Windows app, not XBAP or Silverlight). I want the main app window to support transparency, and show through the desktop below.
But when I specify ToolTip text on a Button, the ToolTip appears beneath (z-order) the main window!
I have a screenshot where: * Another app overlapps and blocks view of the partially transparent main window. * The tooltip from my button appears in front of the other app. * Where the tooltip is not in front of the other app, it is behind the partial transparency.
I read elsewhere that this is a known problem with the WPF engine for 32-bit XP and does not occur in Vista.
What I am looking for is a fix/workaround.
Solution 3
Ok- here's what I found as a workaround:
The problem with ToolTips goes away when the window is also made TopMost.
But I don't want my window to be topmost, so I only do it when my window has keyboard focus:
private void Window_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
this.Topmost = true;
}
private void Window_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
this.Topmost = false;
}
Then I use a binding to enable each ToolTip only when my window is Topmost:
ToolTipService="{Binding ElementName=MainWindow, Path=Topmost}"
This turns off the ToolTip except when it works right. Don't really need tooltips when my window isn't in focus anyway.
Only annoying thing now is that the on/off binding has to be done on every element that defines a Tooltip.
OTHER TIPS
Try the .SetValue(Canvas.ZIndex, 100) method on the UIElement you want on top. (I used 100, only to force the element to the top)
This is a know problem of WIndows XP and WPF (e.g. see here on Connect).
You can avoid the problem by not using a layered window (use one with a frame). I think another solution would be to set the whole window TopMost=true, but for me, that's not a very good solution and I'm not sure about that.
I don't know if MS is tackling this issue, because I think it's quite deep in the graphic layer of XP.