Display Tooltip for Silverlight controls

0 comments
Silverlight offers a class called "ToolTipService" which can be used to display tooltips for Silverlight controls. This class can be attached to most of the UI elements in Silverlight to display tooltips.


Simple Tooltip text


The below sample code shows how to display a simple text tooltip for a Button control:


See this example which sets a tooltip for a textbox control:



<Button Width="60" Height="20" Content="My Button">
    <ToolTipService.ToolTip>
        <ToolTip Content="This is tool tip for Button"></ToolTip>
    </ToolTipService.ToolTip>
</Button>

<TextBlock Width="60" Height="20" Text="My Text">
    <ToolTipService.ToolTip>
        <ToolTip Content="This is tool tip for TextBlock"></ToolTip>
    </ToolTipService.ToolTip>
</TextBlock>

Display rich UI elements in tooltip


Silverlights ability to support UI elements in tooltip can be used to provide great user experience. We can use almost any UI element within a Tooltip. See various examples below.

Display image within a tooltip

This sample code shows how to display an image within a tooltip in Silverlight:


READ MORE >>
http://www.dotnetspider.com/tutorials/Silverlight-Tutorial-320.aspx

0 comments: