Recommended

Skip Navigation LinksHome / Tips / View Tip

Tip: How to add a tooltip to a control?

+ Add to SilverlightShow Favorites
1 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! 

Add Comment

 
 

   
  
  
   
Please add 8 and 2 and type the answer here:

Help us make SilverlightShow even better and win a free t-shirt. Whether you'd like to suggest a change in the structure, content organization, section layout or any other aspect of SilverlightShow appearance - we'd love to hear from you! Need a material (article, tutorial, or other) on a specific topic? Let us know and SilverlightShow content authors will work to have that prepared for you. (hide this)