Tooltip background question

Hello,
How can I set the background of a tool tip to transparent
I tried the following but the background is black - which results in an ugly tooltip.
(Sorry for the basic question, I am newbie at XAML)

Thank you


<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

<Page.Resources>
<Style TargetType ="{x:Type ToolTip}" x:Key="{x:Type ToolTip}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property ="Template">
<Setter.Value>
<ControlTemplate TargetType ="{x:Type ToolTip}">
<Border Background ="{x:Null}" Padding="5">

<Border Background ="Orange" CornerRadius="5"
BorderThickness="1"
BorderBrush="Gray"
TextElement.Foreground="Gray"
>
<ContentPresenter Margin ="3"/>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</Page.Resources>

<Button ToolTip='hello'/>

</Page>



Answer this question

Tooltip background question

  • UZone

    Hi Lester,

    Thanks for your answer.
    However, setting the background to transparent does not work either. Try the following in XAMLPad - The background is black.
    What I wanted is a tooltip with rounded corners. However, WPF seems to place the toolip in a black rectangle.
    I am using XP. Should I use Vista for this

    <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

    <Page.Resources>
    <Style TargetType ="{x:Type ToolTip}" x:Key="{x:Type ToolTip}">
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property ="Template">
    <Setter.Value>
    <ControlTemplate TargetType ="{x:Type ToolTip}">
    <Border Background ="{x:Null}" Padding="5">

    <Border Background ="Transparent" CornerRadius="5"
    BorderThickness="1"
    BorderBrush="Gray"
    TextElement.Foreground="Gray"
    >
    <ContentPresenter Margin ="3"/>
    </Border>
    </Border>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    </Page.Resources>

    <Button ToolTip='hello'/>

    </Page>

  • Eugenio Lysei Junior

    In the newer bits which will be released sometime soon, this has been addressed and the above code should work fine.

    Until then, You might want to try out Michaels solution. :)


  • Aton A

    I think you will find that the ToolTip is not directly displayed within the drawing area, but in a PopUp. You can try styling PopUp for your purposes and see if that does the trick. If the PopUp is in a separate Windows Window then you would need to use the interop solution to use transparency at the window level. I would try the PopUp first and see what that brings to the table.

  • happi.quan

    <Border Background ="Orange" CornerRadius="5"
    BorderThickness="1"
    BorderBrush="Gray"
    TextElement.Foreground="Gray"
    >

    the background should be "transparent" not "Orange"


  • Nicoleta

    Thanks!!!

    Any idea when the new bits will be available



  • Tooltip background question