Creating Fancy Tooltips in WPF

Each control in WPF has a Tooltip property that can be accessed through XAML or code behind. The Tooltip property can host any kind of controls such as a rectangle, text block, or a panel. In other words, we can display another window with any number of controls as a tooltip of a control.
The following code creates a simple tooltip for a button control.
       <Button Width="100" Height="30">Click Me
            <Button.ToolTip>
                <ToolTip>This is a tooltip test for a button control. You
                    can click me if you want but I will do nothing for you.
                ToolTip>
            Button.ToolTip>
        Button>
 
The output looks like Figure 1.
FancyTooltipImg1.jpg
Figure 1. A simple Tooltip
As I said earlier, a Tooltip can host any number of controls. For example, in the below code, a button tooltip hosts a StackPanel with two children StackPanels. First StackPanel hosts an image and a text block and second StackPanel hosts a larger textblock. The output looks like Figure 2, which is a fancy tooltip.


See full details: http://www.vbdotnetheaven.com/UploadFile/dbeniwal321/2259/

Comments

Popular posts from this blog

Asynchronous Socket Programming in C#

Url Routing MVC TUTORIAL

WCF Chat Sample