(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Tip: How to add a tooltip to a control?

(0 votes)
Martin Mihaylov
>
Martin Mihaylov
Joined Oct 29, 2007
Articles:   50
Comments:   70
More Articles
3 comments   /   posted on Sep 11, 2008
Tags:   tooltip , martin-mihaylov
Categories:   Controls

If you want to add a tooltip to a control you must first check if it allows the ToolTipService namespace. If yes, you can add the tooltip the following way:

Xaml

<Button x:Name="MyButton" Content="Hello!" Width="50" Height="30">
    <ToolTipService.ToolTip>
        <TextBlock x:Name="ToolTip" Text="Click me!"></TextBlock>
    </ToolTipService.ToolTip>
</Button>

C#

ToolTipService.SetToolTip( MyButton, new TextBlock() { Text = "Click me!" } );

You can also use another control instead of TextBlock, for example Image control or Rectangle control.

That's it!
 


Subscribe

Comments

  • -_-

    RE: Tip: How to add a tooltip to a control?


    posted by Dekowski411 on Jun 18, 2009 19:25
    I was asked to add this to my client's app and I wasn't sure if this was a Silverlight control...  Thanks for the post! 
  • -_-

    RE: Tip: How to add a tooltip to a control?


    posted by Climb on Jul 22, 2010 09:32
    Thanks very much, before I find your post, I have been failed to try my ways to add a tooltip to a new dynamicly Rectangel.
  • -_-

    Tooltip doing more than one thing


    posted by John on Oct 14, 2010 23:50

    Can you add more than one thing  when firing a tooltip? For instance, add a data bound bubble AND also fire another items' visibility setting? This would be in the code behind of course.


Add Comment

Login to comment:
  *      *