#372 – Defining Tooltips for GUI Elements
August 25, 2011 3 Comments
A tooltip is a small popup that appears when a user hovers the mouse pointer over some user interface element. It’s typically used to provide further information about the element that the user hovers over.
In WPF, you can set a textual tooltip by setting the Tooltip property of a control (inherited from FrameworkElement or FrameworkContentElement class).
<StackPanel> <Label Content="Buy a Tractor:" /> <StackPanel Orientation="Horizontal" > <Label Content="Brand:"/> <RadioButton Content="Deere" ToolTip="Nothing runs like a Deere"/> <RadioButton Content="New Holland" ToolTip="Smart Design. Built Strong. Farm Raised."/> <RadioButton Content="Kubota" ToolTip="The Orange Way"/> </StackPanel> <StackPanel Orientation="Horizontal" > <Label Content="Series:" /> <ComboBox SelectedIndex="0" > <ComboBoxItem Content="BX Series" ToolTip="Little guy"/> <ComboBoxItem Content="B Series" ToolTip="18-32hp, smaller landscaping"/> <ComboBoxItem Content="TLB Series" ToolTip="21-59hp, professional"/> <ComboBoxItem Content="L Series" ToolTip="30-59HP, larger landscaping"/> <ComboBoxItem Content="M Series" ToolTip="43-135hp, all-purpose agricultural"/> </ComboBox> </StackPanel> <Button Content="Buy It" ToolTip="Charge my credit card and send me my tractor" /> </StackPanel>
It’s also worth noting that you can have more advanced tooltips:
Heading
Description blah blah blah
<StackPanel
The RSS feed for this site is one of my favourite RSS feeds – keep up the good work 🙂
Yes, of course. There are a number of posts on tooltips in the pipeline, which will explain lots more about how tooltips work.
Pingback: #873 – Using a Popup Rather than a Tooltip | 2,000 Things You Should Know About WPF