Skip Navigation LinksHome / Tips / View Tip

Tip: How to add a tooltip to a control?

+ Add to SilverlightShow Favorites
4 comments   /   posted by Martin Mihaylov on Sep 11, 2008
(0 votes)
Categories: Controls and UI

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!
 

Share


Comments

Comments RSS RSS
  • 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.
  • RE: Tip: How to add a tooltip to a control?  

    posted by pamela on Jul 23, 2010 17:12

    this is a useful trick how to add a tooltip to a control.

    cheap host

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

    posted by pamela on Jul 23, 2010 17:14

    this is a useful trick how to add a tooltip to a control

    cheap host

Add Comment

 
 

   
  
  
   
Please add 4 and 2 and type the answer here:

Did you notice our new Silverlight-based Showcase section ? Check it out to get a bird's eye view of all showcases featured on SilverlightShow, with a quick thumbnail preview for easier browsing. Want to view the most recent showcases only? Use Group by Month option for a chronological listing.
This is the second redesigned, entirely Silverlight-based section in SilverlightShow, after the new Books section. We look forward to your feedback on both! (hide this)