Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF, Whats with this weird whitespace in Tooltip/Border

Tags:

styles

wpf

I have styled a tooltip like

<Setter Property="ToolTip">
    <Setter.Value>
        <Border Background="Red" CornerRadius="5" Padding="5" Margin="0">
            <TextBlock Text="Hello" Foreground="White" />
        </Border>
    </Setter.Value>
</Setter>

And it gets rendered like

alt text

Whats that white "rectangle" about? How can I get rid of it

like image 978
Jiew Meng Avatar asked Nov 12 '10 04:11

Jiew Meng


2 Answers

That rectangle comes from the ControlTemplate of the ToolTip control wich will contain whatever you set in Control.ToolTip. You have to override it:

<Style TargetType="ToolTip">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ToolTip">
                <ContentPresenter />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
like image 194
bitbonk Avatar answered Nov 05 '22 03:11

bitbonk


Have you tried reducing the padding of the tooltip directly:

<ToolTip Padding="0" >
...
</Tooltip>
like image 2
Robert Gutke Avatar answered Nov 05 '22 03:11

Robert Gutke