Replacing all ToolTips with a custom ToolTip in WPF

Knox 26 Reputation points
2020-11-05T16:32:47.413+00:00

For example, let's say I have this element:

<Button ToolTip="Click here!" />

Instead of the ToolTip being the default WPF ToolTip, can I define a style/template that will replace all default ToolTips with a custom one?

Maybe something like this, where "ToolTipText" would be the text entered in the ToolTip attributes...

<Grid Background="Black">

<TextBlock Text="{Binding ToolTipText}" Foreground="Red" />

</Grid>
Developer technologies Windows Presentation Foundation
0 comments No comments
{count} votes

Accepted answer
  1. DaisyTian-1203 11,646 Reputation points
    2020-11-06T02:27:02.027+00:00

    You can set a Style for Tooltip like this:

    <Window.Resources>  
            <Style TargetType="ToolTip">  
                <Setter Property="Background" Value="Black"></Setter>  
                <Setter Property="Foreground" Value="Red"></Setter>  
            </Style>  
        </Window.Resources>  
        <Grid>  
            <Button Width="160" Height="60" Content="Click" ToolTip="Click here"></Button>  
        </Grid>  
    

    The result picture is like below shown:
    37923-capture.png


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.