#373 – Creating More Complex Tooltips

You typically set a tooltip as a simple textual label, setting the value of the Tooltip property for a control to a text string.  You can also define a more complex tooltip that includes several controls.  In the example below, hovering over one of the tractor brands causes a tooltip to be displayed that shows the logo for the brand.

A tooltip is actually a popup window represented by an instance of the Tooltip control.  Because it inherits from ContentControl, its content can be any .NET object.

You can specify a tooltip’s content in XAML as a child element of the parent control.  The content must be a single element, but can be a container that in turn contains other elements.

            <RadioButton Content="Deere"
                         VerticalAlignment="Center" Margin="5">
                <RadioButton.ToolTip>
                    <StackPanel>
                        <Label Content="John Deere" FontWeight="Bold"/>
                        <Image Source="Deere.jpg"/>
                        <Label Content="Nothing runs like a Deere"/>
                    </StackPanel>
                </RadioButton.ToolTip>
            </RadioButton>
/RadioButton>